From a7d2c9d78296ca19efbebcdbcbafb4b837e6c1df Mon Sep 17 00:00:00 2001 From: Bertjan Broeksema Date: Thu, 8 Nov 2007 22:13:13 +0000 Subject: [PATCH] - 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 --- package.cpp | 4 ++++ tests/plasmoidpackagetest.cpp | 42 +++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/package.cpp b/package.cpp index b3f572795..bb9b43ba2 100644 --- a/package.cpp +++ b/package.cpp @@ -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; diff --git a/tests/plasmoidpackagetest.cpp b/tests/plasmoidpackagetest.cpp index 50a20cf93..fdf87d0bc 100644 --- a/tests/plasmoidpackagetest.cpp +++ b/tests/plasmoidpackagetest.cpp @@ -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 << "This is a test image"; 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);