diff options
author | João Abecasis <joao.abecasis@nokia.com> | 2010-11-25 10:23:10 (GMT) |
---|---|---|
committer | João Abecasis <joao.abecasis@nokia.com> | 2010-11-25 16:25:14 (GMT) |
commit | 83c91bb021e9adf86870c498641e329ab7f786c0 (patch) | |
tree | c322c112fa11464ed1666641886027c09b2cbcee /tests | |
parent | 72fae4bd1bdf5a56632f8ca638f7d1165f6fe1ca (diff) | |
download | Qt-83c91bb021e9adf86870c498641e329ab7f786c0.zip Qt-83c91bb021e9adf86870c498641e329ab7f786c0.tar.gz Qt-83c91bb021e9adf86870c498641e329ab7f786c0.tar.bz2 |
Fix QFile::link unit test
Absolute path for the link target can contain "../" elements and so
needs to be cleaned. Really depends on the definition for SRCDIR.
Reviewed-by: Prasanth Ullattil
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qfile/tst_qfile.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index dbd4302..ba9a8bf 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -1296,22 +1296,28 @@ void tst_QFile::link() QSKIP("Symbian does not support links", SkipAll); #endif QFile::remove("myLink.lnk"); + QFileInfo info1(SRCDIR "tst_qfile.cpp"); + QString referenceTarget = QDir::cleanPath(info1.absoluteFilePath()); + QVERIFY(QFile::link(SRCDIR "tst_qfile.cpp", "myLink.lnk")); + QFileInfo info2("myLink.lnk"); QVERIFY(info2.isSymLink()); - QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath()); + QCOMPARE(info2.symLinkTarget(), referenceTarget); QFile link("myLink.lnk"); QVERIFY(link.open(QIODevice::ReadOnly)); - QCOMPARE(link.symLinkTarget(), info1.absoluteFilePath()); + QCOMPARE(link.symLinkTarget(), referenceTarget); link.close(); - QCOMPARE(QFile::symLinkTarget("myLink.lnk"), info1.absoluteFilePath()); + + QCOMPARE(QFile::symLinkTarget("myLink.lnk"), referenceTarget); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QString wd = getWorkingDirectoryForLink(info2.absoluteFilePath()); - QCOMPARE(QDir::fromNativeSeparators(wd), info1.absolutePath()); + QCOMPARE(QDir::fromNativeSeparators(wd), referenceTarget); #endif + QVERIFY(QFile::remove(info2.absoluteFilePath())); } |