fix the test
This commit is contained in:
parent
b4dbbbb7d0
commit
643045abf3
@ -125,7 +125,7 @@ void PlasmoidPackageTest::createTestPackage(const QString &packageName)
|
|||||||
|
|
||||||
void PlasmoidPackageTest::isValid()
|
void PlasmoidPackageTest::isValid()
|
||||||
{
|
{
|
||||||
p = new Plasma::Package(mPackageRoot, mPackage, ps);
|
p = new Plasma::Package(mPackageRoot + '/' + mPackage, ps);
|
||||||
|
|
||||||
// A PlasmoidPackage is valid when:
|
// A PlasmoidPackage is valid when:
|
||||||
// - The package root exists.
|
// - The package root exists.
|
||||||
@ -138,7 +138,7 @@ void PlasmoidPackageTest::isValid()
|
|||||||
|
|
||||||
// Should still be invalid.
|
// Should still be invalid.
|
||||||
delete p;
|
delete p;
|
||||||
p = new Plasma::Package(mPackageRoot, mPackage, ps);
|
p = new Plasma::Package(mPackageRoot + '/' + mPackage, ps);
|
||||||
QVERIFY(!p->isValid());
|
QVERIFY(!p->isValid());
|
||||||
|
|
||||||
// Create the metadata.desktop file.
|
// Create the metadata.desktop file.
|
||||||
@ -157,7 +157,7 @@ void PlasmoidPackageTest::isValid()
|
|||||||
|
|
||||||
// No main file yet so should still be invalid.
|
// No main file yet so should still be invalid.
|
||||||
delete p;
|
delete p;
|
||||||
p = new Plasma::Package(mPackageRoot, mPackage, ps);
|
p = new Plasma::Package(mPackageRoot + '/' + mPackage, ps);
|
||||||
QVERIFY(!p->isValid());
|
QVERIFY(!p->isValid());
|
||||||
|
|
||||||
// Create the main file.
|
// Create the main file.
|
||||||
@ -172,7 +172,7 @@ void PlasmoidPackageTest::isValid()
|
|||||||
file.setPermissions(QFile::ReadUser | QFile::WriteUser);
|
file.setPermissions(QFile::ReadUser | QFile::WriteUser);
|
||||||
// Main file exists so should be valid now.
|
// Main file exists so should be valid now.
|
||||||
delete p;
|
delete p;
|
||||||
p = new Plasma::Package(mPackageRoot, mPackage, ps);
|
p = new Plasma::Package(mPackageRoot + '/' + mPackage, ps);
|
||||||
QVERIFY(p->isValid());
|
QVERIFY(p->isValid());
|
||||||
QCOMPARE(p->contentsHash(), QString("db0b38c2b4fe21a9f37923cc25152340de055f6d"));
|
QCOMPARE(p->contentsHash(), QString("db0b38c2b4fe21a9f37923cc25152340de055f6d"));
|
||||||
}
|
}
|
||||||
@ -182,7 +182,7 @@ void PlasmoidPackageTest::filePath()
|
|||||||
// Package::filePath() returns
|
// Package::filePath() returns
|
||||||
// - {package_root}/{package_name}/path/to/file if the file exists
|
// - {package_root}/{package_name}/path/to/file if the file exists
|
||||||
// - QString() otherwise.
|
// - QString() otherwise.
|
||||||
p = new Plasma::Package(mPackageRoot, mPackage, ps);
|
p = new Plasma::Package(mPackageRoot + '/' + mPackage, ps);
|
||||||
|
|
||||||
QCOMPARE(p->filePath("scripts", "main"), QString());
|
QCOMPARE(p->filePath("scripts", "main"), QString());
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ void PlasmoidPackageTest::filePath()
|
|||||||
|
|
||||||
// The package is valid by now so a path for code/main should get returned.
|
// The package is valid by now so a path for code/main should get returned.
|
||||||
delete p;
|
delete p;
|
||||||
p = new Plasma::Package(mPackageRoot, mPackage, ps);
|
p = new Plasma::Package(mPackageRoot + '/' + mPackage, ps);
|
||||||
|
|
||||||
const QString path = KStandardDirs::realFilePath(mPackageRoot + "/" + mPackage + "/contents/code/main");
|
const QString path = KStandardDirs::realFilePath(mPackageRoot + "/" + mPackage + "/contents/code/main");
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ void PlasmoidPackageTest::entryList()
|
|||||||
createTestPackage(packageName);
|
createTestPackage(packageName);
|
||||||
|
|
||||||
// Create a package object and verify that it is valid.
|
// 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());
|
QVERIFY(p->isValid());
|
||||||
|
|
||||||
// Now we have a valid package that should contain the following files in
|
// Now we have a valid package that should contain the following files in
|
||||||
@ -243,27 +243,27 @@ void PlasmoidPackageTest::knownPackages()
|
|||||||
// Don't do strange things when package root doesn't exists.
|
// Don't do strange things when package root doesn't exists.
|
||||||
QDir pRoot = QDir(mPackageRoot + "blah");
|
QDir pRoot = QDir(mPackageRoot + "blah");
|
||||||
QVERIFY(!pRoot.exists());
|
QVERIFY(!pRoot.exists());
|
||||||
p = new Plasma::Package(mPackageRoot + "blah", mPackage, ps);
|
p = new Plasma::Package(mPackageRoot + "blah/" + mPackage, ps);
|
||||||
QCOMPARE(Plasma::Package::listInstalled(mPackageRoot), QStringList());
|
QCOMPARE(Plasma::Package::listInstalled(mPackageRoot), QStringList());
|
||||||
delete p;
|
delete p;
|
||||||
|
|
||||||
// Don't do strange things when an empty package root exists
|
// Don't do strange things when an empty package root exists
|
||||||
QVERIFY(QDir().mkpath(mPackageRoot));
|
QVERIFY(QDir().mkpath(mPackageRoot));
|
||||||
//QVERIFY(pRoot.exists());
|
//QVERIFY(pRoot.exists());
|
||||||
p = new Plasma::Package(mPackageRoot, mPackage, ps);
|
p = new Plasma::Package(mPackageRoot + '/' + mPackage, ps);
|
||||||
QCOMPARE(Plasma::Package::listInstalled(mPackageRoot), QStringList());
|
QCOMPARE(Plasma::Package::listInstalled(mPackageRoot), QStringList());
|
||||||
delete p;
|
delete p;
|
||||||
|
|
||||||
// Do not return a directory as package if it has no metadata.desktop file
|
// Do not return a directory as package if it has no metadata.desktop file
|
||||||
QVERIFY(QDir().mkpath(mPackageRoot + "/invalid_plasmoid"));
|
QVERIFY(QDir().mkpath(mPackageRoot + "/invalid_plasmoid"));
|
||||||
p = new Plasma::Package(mPackageRoot, mPackage, ps);
|
p = new Plasma::Package(mPackageRoot + '/' + mPackage, ps);
|
||||||
QCOMPARE(Plasma::Package::listInstalled(mPackageRoot), QStringList());
|
QCOMPARE(Plasma::Package::listInstalled(mPackageRoot), QStringList());
|
||||||
delete p;
|
delete p;
|
||||||
|
|
||||||
// Let's add a valid package and see what happens.
|
// Let's add a valid package and see what happens.
|
||||||
QString plamoid1("a_valid_plasmoid");
|
QString plamoid1("a_valid_plasmoid");
|
||||||
createTestPackage(plamoid1);
|
createTestPackage(plamoid1);
|
||||||
p = new Plasma::Package(mPackageRoot, mPackage, ps);
|
p = new Plasma::Package(mPackageRoot + '/' + mPackage, ps);
|
||||||
|
|
||||||
QStringList packages = Plasma::Package::listInstalled(mPackageRoot);
|
QStringList packages = Plasma::Package::listInstalled(mPackageRoot);
|
||||||
QCOMPARE(packages.size(), 1);
|
QCOMPARE(packages.size(), 1);
|
||||||
@ -272,7 +272,7 @@ void PlasmoidPackageTest::knownPackages()
|
|||||||
// Ok.... one more valid package.
|
// Ok.... one more valid package.
|
||||||
QString plamoid2("another_valid_plasmoid");
|
QString plamoid2("another_valid_plasmoid");
|
||||||
createTestPackage(plamoid2);
|
createTestPackage(plamoid2);
|
||||||
p = new Plasma::Package(mPackageRoot, mPackage, ps);
|
p = new Plasma::Package(mPackageRoot + '/' + mPackage, ps);
|
||||||
|
|
||||||
packages = Plasma::Package::listInstalled(mPackageRoot);
|
packages = Plasma::Package::listInstalled(mPackageRoot);
|
||||||
QCOMPARE(packages.size(), 2);
|
QCOMPARE(packages.size(), 2);
|
||||||
|
Loading…
Reference in New Issue
Block a user