summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2012-02-08 11:28:30 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-14 02:48:35 +0100
commit5c637e9171975a86ec1a3982579cd6f371b1d5ce (patch)
tree34c669c25e8a16abc7066097f30ca3805123de50 /tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
parent3f74aea9bb67bcd2ec463792ee111402f10825d5 (diff)
Add QFileInfo::isNativePath
This function returns true if the file path can be used directly with native APIs, modulo encoding and path separator conversions. This is important for applications that interface with other libraries or simply need to use native APIs together with Qt. Traditionally, this information was available in QAbstractFileEngine and forced users to explicitly create an engine or use internal API such as QFile::fileEngine to access the underlying engine and this piece of information. Given its usefulness, exposing the information in a more visible place is more appropriate. This reduces the need for people to know or care about implementation details, like file engines... The existing isLocalFs test was updated and repurposed to use the new API, instead of relying on file engines and internal implementation details of QFileInfo. Change-Id: I65f497bb25741f6f7ea4d2c3b3562c8c4aab8bea Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Reviewed-by: David Faure <faure@kde.org> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp')
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index a3d80cb66f..797d5ff5e3 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -159,8 +159,8 @@ private slots:
void isBundle_data();
void isBundle();
- void isLocalFs_data();
- void isLocalFs();
+ void isNativePath_data();
+ void isNativePath();
void refresh();
@@ -1222,10 +1222,13 @@ void tst_QFileInfo::isBundle()
QCOMPARE(fi.isBundle(), isBundle);
}
-void tst_QFileInfo::isLocalFs_data()
+void tst_QFileInfo::isNativePath_data()
{
QTest::addColumn<QString>("path");
- QTest::addColumn<bool>("isLocalFs");
+ QTest::addColumn<bool>("isNativePath");
+
+ QTest::newRow("default-constructed") << QString() << false;
+ QTest::newRow("empty") << QString("") << true;
QTest::newRow("local root") << QString::fromLatin1("/") << true;
QTest::newRow("local non-existent file") << QString::fromLatin1("/abrakadabra.boo") << true;
@@ -1233,17 +1236,15 @@ void tst_QFileInfo::isLocalFs_data()
QTest::newRow("qresource root") << QString::fromLatin1(":/") << false;
}
-void tst_QFileInfo::isLocalFs()
+void tst_QFileInfo::isNativePath()
{
QFETCH(QString, path);
- QFETCH(bool, isLocalFs);
+ QFETCH(bool, isNativePath);
QFileInfo info(path);
- QFileInfoPrivate *privateInfo = getPrivate(info);
- QCOMPARE((privateInfo->fileEngine == 0), isLocalFs);
- if (privateInfo->fileEngine)
- QCOMPARE(bool(privateInfo->fileEngine->fileFlags(QAbstractFileEngine::LocalDiskFlag)
- & QAbstractFileEngine::LocalDiskFlag), isLocalFs);
+ if (path.isNull())
+ info = QFileInfo();
+ QCOMPARE(info.isNativePath(), isNativePath);
}
void tst_QFileInfo::refresh()