2008-11-04 00:08:39 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* Copyright 2007 by Aaron Seigo <aseigo@kde.org> *
|
|
|
|
* *
|
|
|
|
* This library is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU Library General Public *
|
|
|
|
* License as published by the Free Software Foundation; either *
|
|
|
|
* version 2 of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This library is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
|
|
|
* Library General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Library General Public License *
|
|
|
|
* along with this library; see the file COPYING.LIB. If not, write to *
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
|
|
|
|
* Boston, MA 02110-1301, USA. *
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
#include "packagestructuretest.h"
|
|
|
|
|
2008-11-04 10:36:00 +01:00
|
|
|
#include <kconfig.h>
|
|
|
|
#include <kconfiggroup.h>
|
|
|
|
#include <kdebug.h>
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2011-07-21 14:48:12 +02:00
|
|
|
#include "applet.h"
|
|
|
|
#include "pluginloader.h"
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2011-07-15 12:58:56 +02:00
|
|
|
class NoPrefixes : public Plasma::Package
|
2010-12-15 08:14:43 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit NoPrefixes()
|
2011-07-15 12:58:56 +02:00
|
|
|
: Plasma::Package()
|
2010-12-15 08:14:43 +01:00
|
|
|
{
|
|
|
|
setContentsPrefixPaths(QStringList());
|
|
|
|
addDirectoryDefinition("bin", "bin", "bin");
|
2011-07-19 21:37:08 +02:00
|
|
|
setPath("/");
|
2010-12-15 08:14:43 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
void PackageStructureTest::init()
|
|
|
|
{
|
2011-07-19 21:37:08 +02:00
|
|
|
m_packagePath = QString::fromLatin1(KDESRCDIR) + "signedPackage/";
|
2011-07-21 14:48:12 +02:00
|
|
|
ps = Plasma::PluginLoader::self()->loadPackage("Plasma/Applet");
|
2011-07-19 21:37:08 +02:00
|
|
|
ps.setPath(m_packagePath);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2010-12-15 08:14:43 +01:00
|
|
|
void PackageStructureTest::emptyContentsPrefix()
|
|
|
|
{
|
2011-07-15 12:58:56 +02:00
|
|
|
NoPrefixes package;
|
2010-12-15 08:14:43 +01:00
|
|
|
QString path(package.filePath("bin", "ls"));
|
2011-07-19 21:37:08 +02:00
|
|
|
//qDebug() << path;
|
2010-12-15 08:14:43 +01:00
|
|
|
QCOMPARE(path, QString("/bin/ls"));
|
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
void PackageStructureTest::directories()
|
|
|
|
{
|
|
|
|
QList<const char*> dirs;
|
2010-10-13 18:02:19 +02:00
|
|
|
dirs << "animations" << "config" << "data" << "images" << "scripts" << "translations" << "ui";
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2011-07-15 12:58:56 +02:00
|
|
|
QList<const char*> psDirs = ps.directories();
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
QCOMPARE(dirs.count(), psDirs.count());
|
2010-10-13 18:02:19 +02:00
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
for (int i = 0; i < psDirs.count(); ++i) {
|
|
|
|
QVERIFY(qstrcmp(dirs[i], psDirs[i]) == 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PackageStructureTest::requiredDirectories()
|
|
|
|
{
|
|
|
|
QList<const char*> dirs;
|
2011-07-15 12:58:56 +02:00
|
|
|
QCOMPARE(ps.requiredDirectories(), dirs);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void PackageStructureTest::files()
|
|
|
|
{
|
|
|
|
QList<const char*> files;
|
2009-09-15 15:08:07 +02:00
|
|
|
files << "defaultconfig" << "mainconfigui" << "mainconfigxml" << "mainscript";
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2011-07-15 12:58:56 +02:00
|
|
|
QList<const char*> psFiles = ps.files();
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2009-09-15 15:08:07 +02:00
|
|
|
//for (int i = 0; i < psFiles.count(); ++i) {
|
|
|
|
// qDebug() << psFiles[i];
|
|
|
|
//}
|
2008-11-04 00:08:39 +01:00
|
|
|
QCOMPARE(files.count(), psFiles.count());
|
|
|
|
for (int i = 0; i < files.count(); ++i) {
|
|
|
|
QCOMPARE(files[i], psFiles[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PackageStructureTest::requiredFiles()
|
|
|
|
{
|
|
|
|
QList<const char*> files;
|
|
|
|
files << "mainscript";
|
|
|
|
|
2011-07-15 12:58:56 +02:00
|
|
|
QList<const char*> psFiles = ps.requiredFiles();
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
QCOMPARE(files.count(), psFiles.count());
|
|
|
|
for (int i = 0; i < files.count(); ++i) {
|
|
|
|
QCOMPARE(files[i], psFiles[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PackageStructureTest::path()
|
|
|
|
{
|
2011-07-19 21:37:08 +02:00
|
|
|
qDebug() << "real paths are" << ps.filePath("images") << ps.filePath("mainscript");
|
|
|
|
qDebug() << "we wants" << QString(m_packagePath + QString("contents/images")) << QString(m_packagePath + QString("contents/code/main.js"));
|
|
|
|
QCOMPARE(ps.filePath("images"), QString(m_packagePath + QString("contents/images")));
|
|
|
|
QCOMPARE(ps.filePath("mainscript"), QString(m_packagePath + QString("contents/code/main.js")));
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void PackageStructureTest::name()
|
|
|
|
{
|
2011-07-15 12:58:56 +02:00
|
|
|
QCOMPARE(ps.name("config"), i18n("Configuration Definitions"));
|
|
|
|
QCOMPARE(ps.name("mainscript"), i18n("Main Script File"));
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void PackageStructureTest::required()
|
|
|
|
{
|
2011-07-15 12:58:56 +02:00
|
|
|
QVERIFY(ps.isRequired("mainscript"));
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2011-05-06 12:26:39 +02:00
|
|
|
void PackageStructureTest::mimeTypes()
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2011-05-06 12:26:39 +02:00
|
|
|
QStringList mimeTypes;
|
|
|
|
mimeTypes << "image/svg+xml" << "image/png" << "image/jpeg";
|
2011-07-15 12:58:56 +02:00
|
|
|
QCOMPARE(ps.mimeTypes("images"), mimeTypes);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QTEST_KDEMAIN(PackageStructureTest, NoGUI)
|
|
|
|
|
|
|
|
//#include "packagestructuretest.moc"
|
|
|
|
|