summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-05-05 14:48:21 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-05-05 15:05:37 (GMT)
commita2f797b52c4274a62a7cf1f0939aca1429afe211 (patch)
tree38b2d4c67f982071e36588f3092d5415addaf721 /tests/auto
parente41217d6d2e592e79a9a8a83c9e49491d66ad18e (diff)
downloadQt-a2f797b52c4274a62a7cf1f0939aca1429afe211.zip
Qt-a2f797b52c4274a62a7cf1f0939aca1429afe211.tar.gz
Qt-a2f797b52c4274a62a7cf1f0939aca1429afe211.tar.bz2
Improve QUrl handling of local file paths
Add QUrl::isLocalFile for a faster and more consistent checking of whether the URL is local or not. Improve the documentation to indicate that QUrl always treats SMB-like file paths as local, even if the system cannot open them (non-Windows). Add a test to ensure that "FILE:/a.txt" is considered local too (RFC 3986 requires schemes to be interpreted in case-insensitive fashion). Remove broken code that supported empty schemes as local file paths. Reviewed-by: Markus Goetz
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qurl/tst_qurl.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index fa42adc..67bf0c1 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -314,6 +314,7 @@ void tst_QUrl::constructing()
QUrl buildUNC;
+ buildUNC.setScheme(QString::fromLatin1("file"));
buildUNC.setHost(QString::fromLatin1("somehost"));
buildUNC.setPath(QString::fromLatin1("somepath"));
QCOMPARE(buildUNC.toLocalFile(), QString::fromLatin1("//somehost/somepath"));
@@ -1757,7 +1758,15 @@ void tst_QUrl::toLocalFile_data()
QTest::newRow("data7") << QString::fromLatin1("file://somehost/") << QString::fromLatin1("//somehost/");
QTest::newRow("data8") << QString::fromLatin1("file://somehost") << QString::fromLatin1("//somehost");
QTest::newRow("data9") << QString::fromLatin1("file:////somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile");
-
+ QTest::newRow("data10") << QString::fromLatin1("FILE:/a.txt") << QString::fromLatin1("/a.txt");
+
+ // and some that result in empty (i.e., not local)
+ QTest::newRow("xdata0") << QString::fromLatin1("/a.txt") << QString();
+ QTest::newRow("xdata1") << QString::fromLatin1("//a.txt") << QString();
+ QTest::newRow("xdata2") << QString::fromLatin1("///a.txt") << QString();
+ QTest::newRow("xdata3") << QString::fromLatin1("foo:/a.txt") << QString();
+ QTest::newRow("xdata4") << QString::fromLatin1("foo://a.txt") << QString();
+ QTest::newRow("xdata5") << QString::fromLatin1("foo:///a.txt") << QString();
}
void tst_QUrl::toLocalFile()