PrismLauncher/tests/tst_userutils.cpp

71 lines
1.6 KiB
C++
Raw Normal View History

2013-12-02 14:51:30 +00:00
#include <QTest>
#include <QStandardPaths>
#include "TestUtil.h"
2015-10-05 00:47:27 +01:00
#include <FileSystem.h>
2013-12-02 14:51:30 +00:00
class UserUtilsTest : public QObject
{
Q_OBJECT
private
slots:
void initTestCase()
{
}
void cleanupTestCase()
{
}
void test_getDesktop()
{
2015-10-05 00:47:27 +01:00
QCOMPARE(FS::getDesktopDir(), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
2013-12-02 14:51:30 +00:00
}
2013-12-17 01:09:58 +00:00
// this is only valid on linux
// FIXME: implement on windows, OSX, then test.
#if defined(Q_OS_LINUX)
2013-12-02 14:51:30 +00:00
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)
2013-12-17 01:09:58 +00:00
<< QByteArray()
2013-12-02 14:51:30 +00:00
#endif
;
}
void test_createShortcut()
{
QFETCH(QString, location);
QFETCH(QString, dest);
QFETCH(QStringList, args);
QFETCH(QString, name);
QFETCH(QString, iconLocation);
QFETCH(QByteArray, result);
2015-10-05 00:47:27 +01:00
QVERIFY(FS::createShortCut(location, dest, args, name, iconLocation));
2013-12-02 14:51:30 +00:00
QCOMPARE(QString::fromLocal8Bit(TestsInternal::readFile(location + QDir::separator() + name + ".desktop")), QString::fromLocal8Bit(result));
//QDir().remove(location);
}
2013-12-17 01:09:58 +00:00
#endif
2013-12-02 14:51:30 +00:00
};
2013-12-17 01:09:58 +00:00
QTEST_GUILESS_MAIN(UserUtilsTest)
2013-12-02 14:51:30 +00:00
#include "tst_userutils.moc"