From 83c91bb021e9adf86870c498641e329ab7f786c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 25 Nov 2010 11:23:10 +0100 Subject: 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 --- tests/auto/qfile/tst_qfile.cpp | 14 ++++++++++---- 1 file 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())); } -- cgit v0.12