diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2009-08-21 13:26:58 (GMT) |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@trolltech.com> | 2009-08-21 13:27:30 (GMT) |
commit | c24d7ff4c933f40326c2c0b50c46ad2b59d88625 (patch) | |
tree | 0a00134b0579acc5c1ae1aa8d36de8cdeef6ebbf /tests/auto/qfileinfo | |
parent | 132811cd923e23832663795ddd3c67d394ffdcfb (diff) | |
download | Qt-c24d7ff4c933f40326c2c0b50c46ad2b59d88625.zip Qt-c24d7ff4c933f40326c2c0b50c46ad2b59d88625.tar.gz Qt-c24d7ff4c933f40326c2c0b50c46ad2b59d88625.tar.bz2 |
autotests for NTFS symlink support on Windows
"Default User" and "Documents and Settings" are mountpoints;
"All Users" is a symlink
If these subtests are successful, then we support both.
Merge-request: 1217
Reviewed-by: Joerg Bornemann <joerg.bornemann@trolltech.com>
Diffstat (limited to 'tests/auto/qfileinfo')
-rw-r--r-- | tests/auto/qfileinfo/tst_qfileinfo.cpp | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 6c94ebf..e9d0d9d 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -139,6 +139,7 @@ private slots: void fileTimes(); void fileTimes_oldFile(); + void isSymLink_data(); void isSymLink(); void isHidden_data(); @@ -166,6 +167,10 @@ private slots: void notEqualOperator() const; }; +tst_QFileInfo::tst_QFileInfo() +{ +} + tst_QFileInfo::~tst_QFileInfo() { QFile::remove("brokenlink.lnk"); @@ -233,12 +238,6 @@ void tst_QFileInfo::copy() QVERIFY(privateInfo->data != privateInfo3->data); QVERIFY(privateInfo2->data != privateInfo3->data); QCOMPARE(privateInfo->data, privateInfo2->data); - - -} - -tst_QFileInfo::tst_QFileInfo() -{ } void tst_QFileInfo::isFile_data() @@ -514,7 +513,6 @@ void tst_QFileInfo::canonicalFilePath() } } #endif - } void tst_QFileInfo::fileName_data() @@ -714,7 +712,6 @@ void tst_QFileInfo::permission_data() QTest::newRow("resource1") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::ReadUser) << true; QTest::newRow("resource2") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::WriteUser) << false; QTest::newRow("resource3") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::ExeUser) << false; - } void tst_QFileInfo::permission() @@ -778,8 +775,8 @@ void tst_QFileInfo::compare_data() #else << false; #endif - } + void tst_QFileInfo::compare() { QFETCH(QString, file1); @@ -946,28 +943,46 @@ void tst_QFileInfo::fileTimes_oldFile() #endif } -void tst_QFileInfo::isSymLink() +void tst_QFileInfo::isSymLink_data() { QFile::remove("link.lnk"); QFile::remove("brokenlink.lnk"); - QFileInfo info1("tst_qfileinfo.cpp"); - QVERIFY( !info1.isSymLink() ); + QFile file1("tst_qfileinfo.cpp"); + QVERIFY(file1.link("link.lnk")); - QFile file2("tst_qfileinfo.cpp"); - if (file2.link("link.lnk")) { - QFileInfo info2("link.lnk"); - QVERIFY( info2.isSymLink() ); - } + QFile file2("dummyfile"); + file2.open(QIODevice::WriteOnly); + QVERIFY(file2.link("brokenlink.lnk")); + file2.remove(); - QFile file3("dummyfile"); - file3.open(QIODevice::WriteOnly); - if (file3.link("brokenlink.lnk")) { - file3.remove(); - QFileInfo info3("brokenlink.lnk"); - QVERIFY( info3.isSymLink() ); + + QTest::addColumn<QString>("path"); + QTest::addColumn<bool>("isSymLink"); + QTest::addColumn<QString>("linkTarget"); + + QTest::newRow("existent file") << "tst_qfileinfo.cpp" << false << ""; + QTest::newRow("link") << "link.lnk" << true << QFileInfo("tst_qfileinfo.cpp").absoluteFilePath(); + QTest::newRow("broken link") << "brokenlink.lnk" << true << QFileInfo("dummyfile").absoluteFilePath(); + +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) + if (QSysInfo::WindowsVersion & QSysInfo::WV_VISTA) { + QTest::newRow("Documents and Settings") << "C:/Documents and Settings" << true << "C:/Users"; + QTest::newRow("All Users") << "C:/Users/All Users" << true << "C:/ProgramData"; + QTest::newRow("Default User") << "C:/Users/Default User" << true << "C:/Users/Default"; } +#endif +} + +void tst_QFileInfo::isSymLink() +{ + QFETCH(QString, path); + QFETCH(bool, isSymLink); + QFETCH(QString, linkTarget); + QFileInfo fi(path); + QCOMPARE(fi.isSymLink(), isSymLink); + QCOMPARE(fi.symLinkTarget(), linkTarget); } void tst_QFileInfo::isHidden_data() |