Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaas Freitag <freitag@owncloud.com>2016-10-12 15:48:00 +0300
committerKlaas Freitag <freitag@owncloud.com>2016-10-12 15:48:00 +0300
commit27d23edaccbf239881e23824cfd9e1de7d04e545 (patch)
treee4e7bb50db7ba1496ca9f770cd69582323211b7a /test/testutility.cpp
parente1a48e3c33161d47ad7f30b0dea30bd350c98b1b (diff)
Utility: Add a function to check if two filenames are equal plus test.
It calls canonical path always and works with the correct case preserving depending on the platform.
Diffstat (limited to 'test/testutility.cpp')
-rw-r--r--test/testutility.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/testutility.cpp b/test/testutility.cpp
index 16fd3066b..63015f053 100644
--- a/test/testutility.cpp
+++ b/test/testutility.cpp
@@ -5,6 +5,9 @@
*/
#include <QtTest>
+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
+#include <QTemporaryDir>
+#endif
#include "utility.h"
@@ -158,6 +161,50 @@ private slots:
s = timeAgoInWords(earlyTS, laterTS );
QCOMPARE(s, QLatin1String("Less than a minute ago"));
}
+
+ void testFsCasePreserving()
+ {
+ qputenv("OWNCLOUD_TEST_CASE_PRESERVING", "1");
+ QVERIFY(fsCasePreserving());
+ qputenv("OWNCLOUD_TEST_CASE_PRESERVING", "0");
+ QVERIFY(! fsCasePreserving());
+ qunsetenv("OWNCLOUD_TEST_CASE_PRESERVING");
+ QVERIFY(isMac() || isWindows() ? fsCasePreserving() : ! fsCasePreserving());
+ }
+
+ void testFileNamesEqual()
+ {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
+ qDebug() << "*** checking fileNamesEqual function";
+ QTemporaryDir dir;
+ QVERIFY(dir.isValid());
+ QDir dir2(dir.path());
+ QVERIFY(dir2.mkpath("test"));
+ if( !fsCasePreserving() ) {
+ QVERIFY(dir2.mkpath("TEST"));
+ }
+ QVERIFY(dir2.mkpath("test/TESTI"));
+ QVERIFY(dir2.mkpath("TESTI"));
+
+ QString a = dir.path();
+ QString b = dir.path();
+
+ QVERIFY(fileNamesEqual(a, b));
+
+ QVERIFY(fileNamesEqual(a+"/test", b+"/test")); // both exist
+ QVERIFY(fileNamesEqual(a+"/test/TESTI", b+"/test/../test/TESTI")); // both exist
+
+ qputenv("OWNCLOUD_TEST_CASE_PRESERVING", "1");
+ QVERIFY(fileNamesEqual(a+"/test", b+"/TEST")); // both exist
+
+ QVERIFY(!fileNamesEqual(a+"/test", b+"/test/TESTI")); // both are different
+
+ dir.remove();
+ qunsetenv("OWNCLOUD_TEST_CASE_PRESERVING");
+#endif
+ }
+
+
};
QTEST_APPLESS_MAIN(TestUtility)