diff options
author | Glenn Watson <glenn.watson@nokia.com> | 2012-07-26 15:00:28 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-31 07:44:12 +0200 |
commit | 9b671727010ccc45cc51840630b159cd34dd983d (patch) | |
tree | 8d316bafd6037e4bd3eda0be657e5811132f41ae /tests/auto/qml/qquickfolderlistmodel | |
parent | f37d7020f986a6e0b3c6d7e9c07ccac2a858b304 (diff) |
Fix folder list model when changing drives on Windows.
The folder list model implementation drops drive letters when
changing folder on Windows. Fix this and add a Windows specific
test case.
Task-number: QTBUG-26620
Change-Id: If58551ba01b56343ebf44512620207e49d83ba09
Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
Diffstat (limited to 'tests/auto/qml/qquickfolderlistmodel')
-rw-r--r-- | tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp index 804bd1a813..b574ef799b 100644 --- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp +++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp @@ -48,6 +48,10 @@ #include <QDebug> #include "../../shared/util.h" +#if defined (Q_OS_WIN) +#include <qt_windows.h> +#endif + // From qquickfolderlistmodel.h const int FileNameRole = Qt::UserRole+1; const int FilePathRole = Qt::UserRole+2; @@ -69,6 +73,9 @@ private slots: void basicProperties(); void resetFiltering(); void refresh(); +#if defined (Q_OS_WIN) + void changeDrive(); +#endif private: void checkNoErrors(const QQmlComponent& component); @@ -174,6 +181,51 @@ void tst_qquickfolderlistmodel::refresh() QTRY_COMPARE(removeEnd, count-1); // wait for refresh } +#if defined (Q_OS_WIN) +void tst_qquickfolderlistmodel::changeDrive() +{ + class DriveMapper + { + public: + DriveMapper(const QString &dataDir) + { + size_t stringLen = dataDir.length(); + targetPath = new wchar_t[stringLen+1]; + dataDir.toWCharArray(targetPath); + targetPath[stringLen] = 0; + + DefineDosDevice(DDD_NO_BROADCAST_SYSTEM, L"X:", targetPath); + } + + ~DriveMapper() + { + DefineDosDevice(DDD_EXACT_MATCH_ON_REMOVE | DDD_NO_BROADCAST_SYSTEM | DDD_REMOVE_DEFINITION, L"X:", targetPath); + delete [] targetPath; + } + + private: + wchar_t *targetPath; + }; + + QString dataDir = testFile(0); + DriveMapper dm(dataDir); + QQmlComponent component(&engine, testFileUrl("basic.qml")); + + QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create()); + QVERIFY(flm != 0); + + QSignalSpy folderChangeSpy(flm, SIGNAL(folderChanged())); + + flm->setProperty("folder",QUrl::fromLocalFile(dataDir)); + QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(dataDir)); + QTRY_VERIFY(folderChangeSpy.count() == 1); + + flm->setProperty("folder",QUrl::fromLocalFile("X:/resetfiltering/")); + QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile("X:/resetfiltering/")); + QTRY_VERIFY(folderChangeSpy.count() == 2); +} +#endif + QTEST_MAIN(tst_qquickfolderlistmodel) #include "tst_qquickfolderlistmodel.moc" |