diff options
Diffstat (limited to 'tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp')
-rw-r--r-- | tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index 59d57ce..963fccc 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -47,7 +47,9 @@ #include <QTime> #include <QStyle> #include <QtGlobal> - +#if defined(Q_OS_SYMBIAN) +# include <f32file.h> +#endif //TESTED_CLASS= //TESTED_FILES= @@ -63,6 +65,23 @@ } \ } while(0) +#if defined(Q_OS_SYMBIAN) +static HBufC* qt_QString2HBufCNewL(const QString& aString) +{ + HBufC *buffer; +#ifdef QT_NO_UNICODE + TPtrC8 ptr(reinterpret_cast<const TUint8*>(aString.toLocal8Bit().constData())); + buffer = HBufC8::NewL(ptr.Length()); + buffer->Des().Copy(ptr); +#else + TPtrC16 ptr(reinterpret_cast<const TUint16*>(aString.utf16())); + buffer = HBufC16::NewL(ptr.Length()); + buffer->Des().Copy(ptr); +#endif + return buffer; +} +#endif + class tst_QFileSystemModel : public QObject { Q_OBJECT @@ -121,6 +140,9 @@ protected: private: QFileSystemModel *model; QString flatDirTestPath; +#if defined(Q_OS_SYMBIAN) + RFs rfs; +#endif }; tst_QFileSystemModel::tst_QFileSystemModel() : model(0) @@ -131,10 +153,16 @@ tst_QFileSystemModel::tst_QFileSystemModel() : model(0) qsrand(midnight.secsTo(QTime::currentTime())); // generating unique temporary directory name flatDirTestPath = QDir::temp().path() + '/' + QString("flatdirtest.") + QString::number(qrand()); +#if defined(Q_OS_SYMBIAN) + rfs.Connect(); +#endif } tst_QFileSystemModel::~tst_QFileSystemModel() { +#if defined(Q_OS_SYMBIAN) + rfs.Close(); +#endif QString tmp = flatDirTestPath; QDir dir(tmp); if (dir.exists() && !dir.rmdir(tmp)) @@ -174,7 +202,7 @@ void tst_QFileSystemModel::cleanup() void tst_QFileSystemModel::indexPath() { -#ifndef Q_OS_WIN +#if !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) int depth = QDir::currentPath().count('/'); model->setRootPath(QDir::currentPath()); QTest::qWait(WAITTIME); @@ -376,6 +404,12 @@ bool tst_QFileSystemModel::createFiles(const QString &test_path, const QStringLi #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) if (initial_files.at(i)[0] == '.') QProcess::execute(QString("attrib +h %1").arg(file.fileName())); +#elif defined(Q_OS_SYMBIAN) + if (initial_files.at(i)[0] == '.') { + HBufC* buffer = qt_QString2HBufCNewL(QDir::toNativeSeparators(file.fileName())); + rfs.SetAtt(*buffer, KEntryAttHidden, 0); + delete buffer; + } #endif //qDebug() << test_path + '/' + initial_files.at(i) << (QFile::exists(test_path + '/' + initial_files.at(i))); } @@ -560,7 +594,7 @@ void tst_QFileSystemModel::filters_data() QTest::addColumn<int>("dirFilters"); QTest::addColumn<QStringList>("nameFilters"); QTest::addColumn<int>("rowCount"); -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QTest::newRow("no dirs") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs) << QStringList() << 2; QTest::newRow("one dir - dotdot") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs | QDir::NoDotAndDotDot) << QStringList() << 1; QTest::newRow("one dir") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs) << QStringList() << 3; @@ -585,7 +619,12 @@ void tst_QFileSystemModel::filters_data() QTest::newRow("no dir + hidden") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::Hidden) << QStringList() << 0; QTest::newRow("dir+hid+files") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::Files | QDir::Hidden) << QStringList() << 3; +#if defined(Q_OS_SYMBIAN) + // Some symbian envs have a bug that causes "A" and ".A" to be considered same name in file system. + QTest::newRow("dir+file+hid-dot .D") << (QStringList() << "a" << "b" << "c") << (QStringList() << ".D") << +#else QTest::newRow("dir+file+hid-dot .A") << (QStringList() << "a" << "b" << "c") << (QStringList() << ".A") << +#endif (int)(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot) << QStringList() << 4; QTest::newRow("dir+files+hid+dot A") << (QStringList() << "a" << "b" << "c") << (QStringList() << "AFolder") << (int)(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot) << (QStringList() << "A*") << 2; @@ -849,7 +888,7 @@ void tst_QFileSystemModel::dirsBeforeFiles() #endif } } - + QTEST_MAIN(tst_QFileSystemModel) #include "tst_qfilesystemmodel.moc" |