summaryrefslogtreecommitdiffstats
path: root/tests/tst_userutils.cpp
blob: 3bc980c07894311982676faf8a21f8168f5af7b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#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));
	}

// this is only valid on linux
// FIXME: implement on windows, OSX, then test.
#if defined(Q_OS_LINUX)
	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)
							  << QByteArray()
						 #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);
	}
#endif
};


QTEST_GUILESS_MAIN_MULTIMC(UserUtilsTest)

#include "tst_userutils.moc"