- The metadata.desktop file is obligatory now for each package.

- Adjusted tests to reflect the fact that the metadata.desktop file is
  obligatory now.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=734451
This commit is contained in:
Bertjan Broeksema 2007-11-08 22:13:13 +00:00
parent 6bba95aa0b
commit a7d2c9d782
2 changed files with 34 additions and 12 deletions

View File

@ -51,6 +51,10 @@ public:
if (valid && basePath[basePath.length() - 1] != '/') {
basePath.append('/');
}
structure.addFileDefinition("metadata", "metadata.desktop",
i18n("Package Meta Data File"));
structure.setRequired("metadata", true);
}
PackageStructure structure;

View File

@ -69,14 +69,24 @@ void PlasmoidPackageTest::createTestPackage(const QString &packageName)
QVERIFY(QDir().mkpath(mPackageRoot));
QVERIFY(QDir().mkpath(mPackageRoot + "/" + packageName));
// Create the metadata.desktop file
QFile file(mPackageRoot + "/" + packageName + "/metadata.desktop");
QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text));
QTextStream out(&file);
out << "[Desktop Entry]\n";
out << "Name=" << packageName << "\n";
file.flush();
file.close();
// Create the code dir.
QVERIFY(QDir().mkpath(mPackageRoot + "/" + packageName + "/code"));
// Create the main file.
QFile file(mPackageRoot + "/" + packageName + "/code/main");
file.setFileName(mPackageRoot + "/" + packageName + "/code/main");
QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text));
QTextStream out(&file);
out << "THIS IS A PLASMOID SCRIPT.....";
file.flush();
file.close();
@ -90,7 +100,6 @@ void PlasmoidPackageTest::createTestPackage(const QString &packageName)
QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text));
out.setDevice(&file);
out << "<svg>This is a test image</svg>";
file.flush();
file.close();
@ -113,33 +122,42 @@ void PlasmoidPackageTest::isValid()
// - The package root exists.
// - The package root consists an file named "code/main"
QVERIFY(!p->isValid());
// Create the root and package dir.
QVERIFY(QDir().mkpath(mPackageRoot));
QVERIFY(QDir().mkpath(mPackageRoot + "/" + mPackage));
// Should still be invalid.
delete p;
p = new Plasma::Package(mPackageRoot, mPackage, *ps);
QVERIFY(!p->isValid());
// Create the metadata.desktop file.
QFile file(mPackageRoot + "/" + mPackage + "/metadata.desktop");
QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text));
QTextStream out(&file);
out << "This is a metadatafile";
file.flush();
file.close();
// Create the code dir.
QVERIFY(QDir().mkpath(mPackageRoot + "/" + mPackage + "/code"));
// No main file yet so should still be invalid.
delete p;
p = new Plasma::Package(mPackageRoot, mPackage, *ps);
QVERIFY(!p->isValid());
// Create the main file.
QFile file(mPackageRoot + "/" + mPackage + "/code/main");
file.setFileName(mPackageRoot + "/" + mPackage + "/code/main");
QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text));
QTextStream out(&file);
out.setDevice(&file);
out << "THIS IS A PLASMOID SCRIPT.....";
file.flush();
file.close();
// Main file exists so should be valid now.
delete p;
p = new Plasma::Package(mPackageRoot, mPackage, *ps);