summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKevin Funk <kevin.funk@kdab.com>2016-01-14 23:33:28 +0100
committerDominik Haumann <dhaumann@kde.org>2016-01-20 13:24:53 +0000
commit8dad3bf2121e3ad5e405665fefa28c4d53192bf7 (patch)
treeda4bfa3c97d13eaf629431ee0916206f09e2525d /tests
parentb530ca770f54165cd2766ccebb7269ba45bccb51 (diff)
Fix toDisplayString(QUrl::PreferLocalFile) on Win
When using QUrl::PreferLocalFile we do want to strip the leading slash, as toLocalFile() would do as well. Behavior change by means of an example: QUrl url(QUrl::fromLocalFile("C:/file.txt") url.toLocalFile() --> "C:/file.txt" Before: url.toDisplayString(QUrl::PreferLocalFile) --> "/C:/file.txt" After: url.toDisplayString(QUrl::PreferLocalFile) --> "C:/file.txt" Task-number: QTBUG-41729 Change-Id: I7d425541f6077ebcf3fcf46feeb7e0f03a0d7fe2 Reviewed-by: Dominik Haumann <dhaumann@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 031a35b380..519b05f492 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -69,6 +69,8 @@ private slots:
void resolving();
void toString_data();
void toString();
+ void toString_PreferLocalFile_data();
+ void toString_PreferLocalFile();
void toString_constructed_data();
void toString_constructed();
void toAndFromStringList_data();
@@ -1050,6 +1052,29 @@ void tst_QUrl::toString()
QCOMPARE(url.adjusted(opt).toString(), string);
}
+void tst_QUrl::toString_PreferLocalFile_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<QString>("string");
+
+#ifdef Q_OS_WIN
+ QTest::newRow("win-drive") << QUrl(QString::fromLatin1("file:///c:/windows/regedit.exe"))
+ << QString::fromLatin1("c:/windows/regedit.exe");
+ QTest::newRow("win-share") << QUrl(QString::fromLatin1("//Anarki/homes"))
+ << QString::fromLatin1("//anarki/homes");
+#else
+ QTest::newRow("unix-path") << QUrl(QString::fromLatin1("file:///tmp"))
+ << QString::fromLatin1("/tmp");
+#endif
+}
+
+void tst_QUrl::toString_PreferLocalFile()
+{
+ QFETCH(QUrl, url);
+ QFETCH(QString, string);
+
+ QCOMPARE(url.toString(QUrl::PreferLocalFile), string);
+}
void tst_QUrl::toAndFromStringList_data()
{