build and pass

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=779707
This commit is contained in:
Aaron J. Seigo 2008-02-26 20:48:02 +00:00
parent a2a6ed7f04
commit aad4f7e305
5 changed files with 36 additions and 34 deletions

View File

@ -7,8 +7,10 @@ MACRO(PLASMA_UNIT_TESTS)
ENDFOREACH(_testname)
ENDMACRO(PLASMA_UNIT_TESTS)
kde4_add_unit_test(packagestructuretest packagestructuretest.cpp) # ../packages.cpp)
target_link_libraries(packagestructuretest plasma ${QT_QTTEST_LIBRARY})
PLASMA_UNIT_TESTS(
packagestructuretest
packagemetadatatest
plasmoidpackagetest
)

View File

@ -24,16 +24,15 @@
#include <KDebug>
#include "plasma/packagestructure.h"
#include "plasma/packages.cpp"
#include "plasma/applet.h"
void PackageStructureTest::init()
{
ps = new Plasma::PlasmoidStructure;
ps = Plasma::Applet::packageStructure();
}
void PackageStructureTest::cleanup()
{
delete ps;
}
void PackageStructureTest::type()
@ -44,13 +43,13 @@ void PackageStructureTest::type()
void PackageStructureTest::directories()
{
QList<const char*> dirs;
dirs << "config" << "configui" << "images" << "scripts";
dirs << "config" << "images" << "scripts" << "ui";
QList<const char*> psDirs = ps->directories();
QCOMPARE(dirs.count(), psDirs.count());
for (int i = 0; i < dirs.count(); ++i) {
QCOMPARE(dirs[i], psDirs[i]);
for (int i = 0; i < psDirs.count(); ++i) {
QVERIFY(qstrcmp(dirs[i], psDirs[i]) == 0);
}
}
@ -114,8 +113,8 @@ void PackageStructureTest::read()
{
QString structurePath = QString(KDESRCDIR) + "/plasmoidpackagerc";
KConfig config(structurePath);
Plasma::PackageStructure structure =
Plasma::PackageStructure::read(&config);
Plasma::PackageStructure structure;
structure.read(&config);
// check some names
QCOMPARE(structure.name("config"), i18n("Configuration Definitions"));
@ -165,11 +164,14 @@ void PackageStructureTest::write()
// check groups
QStringList groups;
groups << "images" << "config" << "configui" << "scripts"
<< "mainconfiggui" << "mainconfigxml" << "mainscript";
groups << "images" << "config" << "scripts"
<< "mainconfiggui" << "mainconfigxml" << "mainscript" << "ui";
groups.sort();
QCOMPARE(config.groupList(), groups);
QStringList actualGroups = config.groupList();
actualGroups.sort();
QCOMPARE(actualGroups, groups);
// check scripts
KConfigGroup scripts = config.group("scripts");
QCOMPARE(scripts.readEntry("Path", QString()), QString("code"));

View File

@ -21,7 +21,7 @@
#include <qtest_kde.h>
#include "plasma/packages_p.h"
#include "plasma/packagestructure.h"
class PackageStructureTest : public QObject
{
@ -47,7 +47,7 @@ private Q_SLOTS:
//TODO: add tests for copy construction
private:
Plasma::PackageStructure *ps;
Plasma::PackageStructure::Ptr ps;
};
#endif

View File

@ -23,21 +23,19 @@
#include <QFile>
#include <KZip>
#include "plasma/applet.h"
#include "plasma/packagemetadata.h"
#include "plasma/packages.cpp"
void PlasmoidPackageTest::init()
{
mPackage = QString("Package");
mPackageRoot = QDir::homePath() + "/.kde-unit-test/packageRoot";
ps = new Plasma::PlasmoidStructure;
ps = Plasma::Applet::packageStructure();
}
void PlasmoidPackageTest::cleanup()
{
delete ps;
if( p )
{
delete p;
@ -131,7 +129,7 @@ void PlasmoidPackageTest::createTestPackage(const QString &packageName)
void PlasmoidPackageTest::isValid()
{
p = new Plasma::Package(mPackageRoot, mPackage, *ps);
p = new Plasma::Package(mPackageRoot, mPackage, ps);
// A PlasmoidPackage is valid when:
// - The package root exists.
@ -144,7 +142,7 @@ void PlasmoidPackageTest::isValid()
// Should still be invalid.
delete p;
p = new Plasma::Package(mPackageRoot, mPackage, *ps);
p = new Plasma::Package(mPackageRoot, mPackage, ps);
QVERIFY(!p->isValid());
// Create the metadata.desktop file.
@ -163,7 +161,7 @@ void PlasmoidPackageTest::isValid()
// No main file yet so should still be invalid.
delete p;
p = new Plasma::Package(mPackageRoot, mPackage, *ps);
p = new Plasma::Package(mPackageRoot, mPackage, ps);
QVERIFY(!p->isValid());
// Create the main file.
@ -177,7 +175,7 @@ void PlasmoidPackageTest::isValid()
// Main file exists so should be valid now.
delete p;
p = new Plasma::Package(mPackageRoot, mPackage, *ps);
p = new Plasma::Package(mPackageRoot, mPackage, ps);
QVERIFY(p->isValid());
}
@ -186,7 +184,7 @@ void PlasmoidPackageTest::filePath()
// Package::filePath() returns
// - {package_root}/{package_name}/path/to/file if the file exists
// - QString() otherwise.
p = new Plasma::Package(mPackageRoot, mPackage, *ps);
p = new Plasma::Package(mPackageRoot, mPackage, ps);
QCOMPARE(p->filePath("scripts", "main"), QString());
@ -201,7 +199,7 @@ void PlasmoidPackageTest::filePath()
// The package is valid by now so a path for code/main should get returned.
delete p;
p = new Plasma::Package(mPackageRoot, mPackage, *ps);
p = new Plasma::Package(mPackageRoot, mPackage, ps);
QString path = mPackageRoot + "/" + mPackage + "/contents/code/main";
@ -224,7 +222,7 @@ void PlasmoidPackageTest::entryList()
createTestPackage(packageName);
// Create a package object and verify that it is valid.
p = new Plasma::Package(mPackageRoot, packageName, *ps);
p = new Plasma::Package(mPackageRoot, packageName, ps);
QVERIFY(p->isValid());
// Now we have a valid package that should contain the following files in
@ -247,27 +245,27 @@ void PlasmoidPackageTest::knownPackages()
// Don't do strange things when package root doesn't exists.
QDir pRoot = QDir(mPackageRoot + "blah");
QVERIFY(!pRoot.exists());
p = new Plasma::Package(mPackageRoot + "blah", mPackage, *ps);
p = new Plasma::Package(mPackageRoot + "blah", mPackage, ps);
QCOMPARE(p->knownPackages(mPackageRoot), QStringList());
delete p;
// Don't do strange things when an empty package root exists
QVERIFY(QDir().mkpath(mPackageRoot));
//QVERIFY(pRoot.exists());
p = new Plasma::Package(mPackageRoot, mPackage, *ps);
p = new Plasma::Package(mPackageRoot, mPackage, ps);
QCOMPARE(p->knownPackages(mPackageRoot), QStringList());
delete p;
// Do not return a directory as package if it has no metadata.desktop file
QVERIFY(QDir().mkpath(mPackageRoot + "/invalid_plasmoid"));
p = new Plasma::Package(mPackageRoot, mPackage, *ps);
p = new Plasma::Package(mPackageRoot, mPackage, ps);
QCOMPARE(p->knownPackages(mPackageRoot), QStringList());
delete p;
// Let's add a valid package and see what happens.
QString plamoid1("a_valid_plasmoid");
createTestPackage(plamoid1);
p = new Plasma::Package(mPackageRoot, mPackage, *ps);
p = new Plasma::Package(mPackageRoot, mPackage, ps);
QStringList packages = p->knownPackages(mPackageRoot);
QCOMPARE(packages.size(), 1);
@ -276,7 +274,7 @@ void PlasmoidPackageTest::knownPackages()
// Ok.... one more valid package.
QString plamoid2("anoter_valid_plasmoid");
createTestPackage(plamoid2);
p = new Plasma::Package(mPackageRoot, mPackage, *ps);
p = new Plasma::Package(mPackageRoot, mPackage, ps);
packages = p->knownPackages(mPackageRoot);
QCOMPARE(packages.size(), 2);
@ -290,7 +288,7 @@ void PlasmoidPackageTest::metadata()
createTestPackage(plasmoid);
QString path = mPackageRoot + '/' + plasmoid + "/metadata.desktop";
p = new Plasma::Package(mPackageRoot, plasmoid, *ps);
p = new Plasma::Package(mPackageRoot, plasmoid, ps);
const Plasma::PackageMetadata *metadata = p->metadata();
QVERIFY(metadata);
QCOMPARE(metadata->name(), plasmoid);
@ -327,7 +325,7 @@ void PlasmoidPackageTest::createAndInstallPackage()
QVERIFY(QFile::exists(installedPackage));
p = new Plasma::Package(installedPackage, *ps);
p = new Plasma::Package(installedPackage, ps);
QVERIFY(p->isValid());
}

View File

@ -45,7 +45,7 @@ private:
QString mPackageRoot;
QString mPackage;
Plasma::PackageStructure *ps;
Plasma::PackageStructure::Ptr ps;
Plasma::Package *p;
};