add a test for "contentsPrefixPaths() == QStringList() is ultimately the same as contentsPrefixPaths() == QStringList() << QString()"; proved that this worked as expected (which i knew) but exposed a bug in PackageStructure. huzzah for unit tests.

svn path=/trunk/KDE/kdelibs/; revision=1206643
This commit is contained in:
Aaron J. Seigo 2010-12-15 07:14:43 +00:00
parent 65d5227bec
commit 03a4645d5a
2 changed files with 23 additions and 0 deletions

View File

@ -23,9 +23,22 @@
#include <kconfiggroup.h> #include <kconfiggroup.h>
#include <kdebug.h> #include <kdebug.h>
#include "plasma/package.h"
#include "plasma/packagestructure.h" #include "plasma/packagestructure.h"
#include "plasma/applet.h" #include "plasma/applet.h"
class NoPrefixes : public Plasma::PackageStructure
{
public:
explicit NoPrefixes()
: Plasma::PackageStructure(0, "StructureLess")
{
setContentsPrefixPaths(QStringList());
addDirectoryDefinition("bin", "bin", "bin");
}
};
void PackageStructureTest::init() void PackageStructureTest::init()
{ {
ps = Plasma::Applet::packageStructure(); ps = Plasma::Applet::packageStructure();
@ -35,6 +48,15 @@ void PackageStructureTest::cleanup()
{ {
} }
void PackageStructureTest::emptyContentsPrefix()
{
Plasma::PackageStructure::Ptr structure(new NoPrefixes);
Plasma::Package package("/", structure);
QString path(package.filePath("bin", "ls"));
qDebug() << path;
QCOMPARE(path, QString("/bin/ls"));
}
void PackageStructureTest::type() void PackageStructureTest::type()
{ {
QCOMPARE(ps->type(), QString("Plasmoid")); QCOMPARE(ps->type(), QString("Plasmoid"));

View File

@ -32,6 +32,7 @@ public Q_SLOTS:
void cleanup(); void cleanup();
private Q_SLOTS: private Q_SLOTS:
void emptyContentsPrefix();
void type(); void type();
void directories(); void directories();
void requiredDirectories(); void requiredDirectories();