diff options
author | David Faure <faure@kde.org> | 2012-03-02 15:41:51 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-07 16:13:44 +0100 |
commit | a6a7cabcd3b38dbd65570a23a800d7e3800a78d0 (patch) | |
tree | fc73fb8da0eef8d3f8ec037e756b2ba90e748332 /tests/auto/corelib/io/qurl | |
parent | e1b2755083c8b30d2062108ea490f9c49729cf3b (diff) |
Add QUrl formatting option "PreferLocalFile".
For the readonly case (e.g. progress dialogs), where local file paths
look much nicer to end users than file:/// URLs.
Change-Id: I899fed27cfb73ebf565389cfd489d2d2fcbeac7c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests/auto/corelib/io/qurl')
-rw-r--r-- | tests/auto/corelib/io/qurl/tst_qurl.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index f782b26b46..3bff330db2 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -262,9 +262,16 @@ void tst_QUrl::hashInPath() QCOMPARE(withHashInPath.path(), QString::fromLatin1("hi#mum.txt")); QCOMPARE(withHashInPath.toEncoded(), QByteArray("hi%23mum.txt")); QCOMPARE(withHashInPath.toString(), QString("hi%23mum.txt")); + QCOMPARE(withHashInPath.toDisplayString(QUrl::PreferLocalFile), QString("hi%23mum.txt")); QUrl fromHashInPath = QUrl::fromEncoded(withHashInPath.toEncoded()); QVERIFY(withHashInPath == fromHashInPath); + + const QUrl localWithHash = QUrl::fromLocalFile("/hi#mum.txt"); + QCOMPARE(localWithHash.path(), QString::fromLatin1("/hi#mum.txt")); + QCOMPARE(localWithHash.toEncoded(), QByteArray("file:///hi%23mum.txt")); + QCOMPARE(localWithHash.toString(), QString("file:///hi%23mum.txt")); + QCOMPARE(localWithHash.toDisplayString(QUrl::PreferLocalFile), QString("/hi#mum.txt")); } void tst_QUrl::unc() @@ -352,6 +359,7 @@ void tst_QUrl::setUrl() QCOMPARE(url.port(), -1); QCOMPARE(url.toString(), QString::fromLatin1("file:///")); QCOMPARE(url.toDisplayString(), QString::fromLatin1("file:///")); + QCOMPARE(url.toDisplayString(QUrl::PreferLocalFile), QString::fromLatin1("/")); } { @@ -367,6 +375,7 @@ void tst_QUrl::setUrl() QCOMPARE(url.port(), 80); QCOMPARE(url.toString(), QString::fromLatin1("http://www.foo.bar:80")); QCOMPARE(url.toDisplayString(), QString::fromLatin1("http://www.foo.bar:80")); + QCOMPARE(url.toDisplayString(QUrl::PreferLocalFile), QString::fromLatin1("http://www.foo.bar:80")); QUrl url2("//www1.foo.bar"); QCOMPARE(url.resolved(url2).toString(), QString::fromLatin1("http://www1.foo.bar")); @@ -451,15 +460,7 @@ void tst_QUrl::setUrl() QUrl url = u1; QVERIFY(url.isValid()); QCOMPARE(url.toString(), QString::fromLatin1("file:///home/dfaure/my#myref")); - QCOMPARE(url.fragment(), QString::fromLatin1("myref")); - } - - { - QString u1 = "file:/home/dfaure/my#myref"; - QUrl url = u1; - QVERIFY(url.isValid()); - - QCOMPARE(url.toString(), QString::fromLatin1("file:///home/dfaure/my#myref")); + QCOMPARE(url.toString(QUrl::PreferLocalFile), QString::fromLatin1("file:///home/dfaure/my#myref")); QCOMPARE(url.fragment(), QString::fromLatin1("myref")); } |