summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2013-12-02 15:51:30 +0100
committerJan Dalheimer <jan@dalheimer.de>2013-12-02 15:51:30 +0100
commit1167a66ac89d1510fbb522544e9733cc086f35eb (patch)
treeef3dd735dc400290baec8c845890f28ca211a6c3 /tests
parentbefeeaa15c75485e93d0acaa91bfd7eba7b3d5f7 (diff)
downloadMultiMC-1167a66ac89d1510fbb522544e9733cc086f35eb.tar
MultiMC-1167a66ac89d1510fbb522544e9733cc086f35eb.tar.gz
MultiMC-1167a66ac89d1510fbb522544e9733cc086f35eb.tar.lz
MultiMC-1167a66ac89d1510fbb522544e9733cc086f35eb.tar.xz
MultiMC-1167a66ac89d1510fbb522544e9733cc086f35eb.zip
Tests for the user utils
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rwxr-xr-xtests/data/tst_userutils-test_createShortcut-unix6
-rw-r--r--tests/tst_userutils.cpp66
3 files changed, 73 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index f2a005e1..20863c73 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -22,6 +22,7 @@ endmacro()
# Tests START #
add_unit_test2(pathutils)
+add_unit_test2(userutils)
# Tests END #
diff --git a/tests/data/tst_userutils-test_createShortcut-unix b/tests/data/tst_userutils-test_createShortcut-unix
new file mode 100755
index 00000000..1ce3a2bd
--- /dev/null
+++ b/tests/data/tst_userutils-test_createShortcut-unix
@@ -0,0 +1,6 @@
+[Desktop Entry]
+Type=Application
+TryExec=asdfDest
+Exec=asdfDest 'arg1' 'arg2'
+Name=asdf
+Icon=
diff --git a/tests/tst_userutils.cpp b/tests/tst_userutils.cpp
new file mode 100644
index 00000000..62bee985
--- /dev/null
+++ b/tests/tst_userutils.cpp
@@ -0,0 +1,66 @@
+#include <QTest>
+#include <QStandardPaths>
+#include "TestUtil.h"
+
+#include "depends/util/include/userutils.h"
+
+class UserUtilsTest : public QObject
+{
+ Q_OBJECT
+private
+slots:
+ void initTestCase()
+ {
+
+ }
+ void cleanupTestCase()
+ {
+
+ }
+
+ void test_getDesktop()
+ {
+ QCOMPARE(Util::getDesktopDir(), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
+ }
+
+ void test_createShortcut_data()
+ {
+ QTest::addColumn<QString>("location");
+ QTest::addColumn<QString>("dest");
+ QTest::addColumn<QStringList>("args");
+ QTest::addColumn<QString>("name");
+ QTest::addColumn<QString>("iconLocation");
+ QTest::addColumn<QByteArray>("result");
+
+ QTest::newRow("unix") << QDir::currentPath()
+ << "asdfDest"
+ << (QStringList() << "arg1" << "arg2")
+ << "asdf"
+ << QString()
+ #if defined(Q_OS_LINUX)
+ << MULTIMC_GET_TEST_FILE("data/tst_userutils-test_createShortcut-unix")
+ #elif defined(Q_OS_WIN)
+ << QString()
+ #endif
+ ;
+ }
+
+ void test_createShortcut()
+ {
+ QFETCH(QString, location);
+ QFETCH(QString, dest);
+ QFETCH(QStringList, args);
+ QFETCH(QString, name);
+ QFETCH(QString, iconLocation);
+ QFETCH(QByteArray, result);
+
+ QVERIFY(Util::createShortCut(location, dest, args, name, iconLocation));
+ QCOMPARE(QString::fromLocal8Bit(TestsInternal::readFile(location + QDir::separator() + name + ".desktop")), QString::fromLocal8Bit(result));
+
+ //QDir().remove(location);
+ }
+};
+
+QTEST_GUILESS_MAIN_MULTIMC(UserUtilsTest)
+
+#include "tst_userutils.moc"