Remove deprecated tests

Summary:
Plasma::KPackage is deprecated in favour of KPackage.
There are much better tests there.

Storage is completely unused, no point testing it.

Test Plan: Compiles

Reviewers: #plasma

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D22611
This commit is contained in:
David Edmundson 2019-07-21 16:06:12 +02:00
parent 249365e327
commit 0e14ab6eca
8 changed files with 0 additions and 700 deletions

View File

@ -36,23 +36,13 @@ ENDMACRO(PLASMA_UNIT_TESTS)
PLASMA_UNIT_TESTS(
dialogqmltest
dialogstatetest
fallbackpackagetest
packagestructuretest
pluginloadertest
framesvgtest
iconitemtest
themetest
configmodeltest
# plasmoidpackagetest
)
set(storagetest_libs Qt5::Gui Qt5::Test Qt5::Sql KF5::KIOCore KF5::Plasma KF5::CoreAddons)
if(QT_QTOPENGL_FOUND)
list(APPEND storagetest_libs Qt5::OpenGL)
endif()
set(storagetest_srcs storagetest.cpp ../src/plasma/private/storage.cpp ../src/plasma/private/storagethread.cpp ../src/plasma/debug_p.cpp)
ecm_add_test(${storagetest_srcs} TEST_NAME plasma-storagetest LINK_LIBRARIES ${storagetest_libs})
if(HAVE_X11)
set(dialognativetest_srcs dialognativetest.cpp)
ecm_add_test(${dialognativetest_srcs} TEST_NAME dialognativetest LINK_LIBRARIES Qt5::Gui Qt5::Test Qt5::Qml Qt5::Quick KF5::WindowSystem KF5::Plasma KF5::PlasmaQuick)

View File

@ -1,71 +0,0 @@
/******************************************************************************
* Copyright 2007 by Aaron Seigo <aseigo@kde.org> *
* Copyright 2014 Marco Martin <mart@kde.org> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; see the file COPYING.LIB. If not, write to *
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301, USA. *
*******************************************************************************/
#include "fallbackpackagetest.h"
#include <QDebug>
#include "packagestructure.h"
#include "pluginloader.h"
void FallbackPackageTest::initTestCase()
{
m_fallPackagePath = QFINDTESTDATA("data/testpackage");
m_fallbackPkg = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/Generic"));
m_fallbackPkg.setPath(m_fallPackagePath);
m_packagePath = QFINDTESTDATA("data/testfallbackpackage");
m_pkg = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/Generic"));
m_pkg.setPath(m_packagePath);
}
void FallbackPackageTest::beforeFallback()
{
QVERIFY(m_fallbackPkg.hasValidStructure());
QVERIFY(m_pkg.hasValidStructure());
//m_fallbackPkg should have otherfile.qml, m_pkg shouldn't
QVERIFY(!m_fallbackPkg.filePath("ui", QStringLiteral("otherfile.qml")).isEmpty());
QVERIFY(m_pkg.filePath("ui", QStringLiteral("otherfile.qml")).isEmpty());
}
void FallbackPackageTest::afterFallback()
{
m_pkg.setFallbackPackage(m_fallbackPkg);
//after setting the fallback, m_pkg should resolve the exact same file as m_fallbackPkg
// for otherfile.qml
QVERIFY(!m_pkg.filePath("ui", QStringLiteral("otherfile.qml")).isEmpty());
QCOMPARE(m_fallbackPkg.filePath("ui", QStringLiteral("otherfile.qml")), m_pkg.filePath("ui", QStringLiteral("otherfile.qml")));
QVERIFY(m_fallbackPkg.filePath("mainscript") != m_pkg.filePath("mainscript"));
}
void FallbackPackageTest::cycle()
{
m_fallbackPkg.setFallbackPackage(m_pkg);
m_pkg.setFallbackPackage(m_fallbackPkg);
//The cycle should have been detected and filePath should take a not infinite time
QTRY_COMPARE_WITH_TIMEOUT(m_fallbackPkg.filePath("ui", QStringLiteral("otherfile.qml")), m_pkg.filePath("ui", QStringLiteral("otherfile.qml")), 1000);
}
QTEST_MAIN(FallbackPackageTest)

View File

@ -1,46 +0,0 @@
/******************************************************************************
* Copyright 2007 by Aaron Seigo <aseigo@kde.org> *
* Copyright 2014 Marco Martin <mart@kde.org> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; see the file COPYING.LIB. If not, write to *
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301, USA. *
*******************************************************************************/
#ifndef FALLBACKPACKAGETEST_H
#include <QtTest>
#include "plasma/package.h"
class FallbackPackageTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void beforeFallback();
void afterFallback();
void cycle();
private:
Plasma::Package m_pkg;
Plasma::Package m_fallbackPkg;
QString m_packagePath;
QString m_fallPackagePath;
};
#endif

View File

@ -1,103 +0,0 @@
[Desktop Entry]
Name=Package metadata test file
Name[ar]=ملف اختبار بيانات الحزمة الوصفية
Name[bs]=Test datoteka paketa metapodataka
Name[ca]=Fitxer de proves per a les metadades del paquet
Name[ca@valencia]=Fitxer de proves per a les metadades del paquet
Name[cs]=Testovací soubor metadat balíčku
Name[da]=Testfil med pakkemetadata
Name[de]=Testdatei für Paket-Metadaten
Name[en_GB]=Package metadata test file
Name[es]=Archivo de pruebas de metadatos de paquete
Name[fi]=Pakettimetatietojen testitiedosto
Name[fr]=Fichier de test de métadonnées de paquets
Name[gd]=Faidhle deuchainneach e pacaid mheata-dàta
Name[gl]=Ficheiro de proba de metadatos de paquete
Name[hu]=Tesztfájl csomagok metaadatához
Name[ia]=File de prova del pacchetto metadata
Name[it]=File di prova metadati pacchetto
Name[ko]=
Name[lt]=Paketo metaduomenų bandomasis failas
Name[mr]=
Name[nb]=Testfil for Package metadata
Name[nds]=Paketmetadaten-Testdatei
Name[nl]=Testbestand voor pakketmetadata
Name[nn]=Testfil for pakkemetadata
Name[pa]=
Name[pl]=Plik próbny pakietu metadanych
Name[pt]=Ficheiro de testes de meta-dados dos pacotes
Name[pt_BR]=Arquivo de teste dos metadados do pacote
Name[ru]=Тестовый файл метаданных пакета
Name[sk]=Testovací súbor metadát balíčku
Name[sl]=Preizkusna datoteka metapodatkov paketa
Name[sr]=Пробни фајл метаподатака пакета
Name[sr@ijekavian]=Пробни фајл метаподатака пакета
Name[sr@ijekavianlatin]=Probni fajl metapodataka paketa
Name[sr@latin]=Probni fajl metapodataka paketa
Name[sv]=Testfil för paketmetadata
Name[tr]=Paket metadata test dosyası
Name[ug]=بوغچا مېتا سانلىق-مەلۇمات سىناق ھۆججەت
Name[uk]=Файл перевірки метаданих пакунка
Name[x-test]=xxPackage metadata test filexx
Name[zh_CN]=
Name[zh_TW]=
Comment=A test desktop file to test the PackageMetaData class.
Comment[ar]=ملف سطح مكتب اختباري لاختبار صنف بيانات الحزمة الوصفية (PackageMetaData).
Comment[bs]=Probna .desktop datoteka za klasu PackageMetaData.
Comment[ca]=Un fitxer d'escriptori de proves per provar la classe «PackageMetaData».
Comment[ca@valencia]=Un fitxer d'escriptori de proves per provar la classe «PackageMetaData».
Comment[cs]=Testovací soubor plochy pro otestování třídy PackageMetaData.
Comment[da]=En test-desktop-fil til at teste PackageMetaData-klassen.
Comment[de]=Eine Test-Desktop-Datei zum Testen der Klasse PackageMetaData.
Comment[en_GB]=A test desktop file to test the PackageMetaData class.
Comment[es]=Un archivo de escritorio para probar la clase PackageMetaData.
Comment[fi]=Kokeellinen desktop-tiedosto PackageMetaData-luokan testaamiseen.
Comment[fr]=Un fichier « desktop » de test pour tester la classe PackageMetaData.
Comment[gd]=Faidhle desktop deuchainneach gus deuchainn a dhèanamh air a' chlas PackageMetaData.
Comment[gl]=Un ficheiro de escritorio de proba para probar a clase PackageMetaData.
Comment[hu]=Teszt .desktop fájl a PackageMetaData osztály teszteléséhez.
Comment[ia]=Un file de prova del scriptorio pro provar le classe PackageMetaData.
Comment[it]=Un file desktop di test per provare la classe PackageMetaData.
Comment[ko]=PackageMetaData .
Comment[lt]=Bandomasis desktop failas skirtas PackageMetaData klasei.
Comment[mr]= .
Comment[nb]=En skrivebordsfil med testdata for klassen PackageMetaData.
Comment[nds]=En Test-Schriefdischdatei för't Utproberen vun de Klass PackageMetaData.
Comment[nl]=Een desktop-bestand voor het testen van de PackageMetaData-klasse.
Comment[nn]=Ei .desktop-fil for testing av PackageMetaData-klassen.
Comment[pa]=PackageMetaData
Comment[pl]=Plik próbny desktop do wypróbowania klasy PackageMetaData.
Comment[pt]=Um ficheiro 'desktop' de testes da classe PackageMetaData.
Comment[pt_BR]=Um arquivo desktop de testes para a classe PackageMetaData.
Comment[ru]=Тестовый файл .desktop для проверки класса PackageMetaData.
Comment[sk]=Testovací súbor plochy na testovanie triedy PackageMetaData.
Comment[sl]=Preizkusna namizna datoteka za preizkus razreda PackageMetaData.
Comment[sr]=Пробни .десктоп фајл за класу PackageMetaData.
Comment[sr@ijekavian]=Пробни .десктоп фајл за класу PackageMetaData.
Comment[sr@ijekavianlatin]=Probni .desktop fajl za klasu PackageMetaData.
Comment[sr@latin]=Probni .desktop fajl za klasu PackageMetaData.
Comment[sv]=En skrivbordsfil för att testa klassen PackageMetaData.
Comment[tr]=PackageMetaData sınıfını test etmek için bir desktop dosyası.
Comment[ug]=PackageMetaData خىلىدىكى سىناشقا ئىشلىتىدىغان desktop تىپىدىكى ھۆججەت.
Comment[uk]=Тестовий стільничний файл для перевірки класу PackageMetaData.
Comment[x-test]=xxA test desktop file to test the PackageMetaData class.xx
Comment[zh_CN]= PackageMetaData desktop
Comment[zh_TW]= PackageMetaData
Icon=test
Type=Service
X-KDE-ServiceTypes=Plasma/Applet
X-KDE-Screenshot=a_not_default_file.svg
X-KDE-Library=some_test_library
X-KDE-PluginInfo-Author=Bertjan Broeksema
X-KDE-PluginInfo-Email=b.broeksema@kdemail.net
X-KDE-PluginInfo-Name=test
X-KDE-PluginInfo-Version=pre0.1
X-KDE-PluginInfo-Website=https://plasma.kde.org/
X-KDE-PluginInfo-Category=System test
X-KDE-PluginInfo-Depends=some_test_dep
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
X-KDE-ParentApp=A Test name

View File

@ -1,276 +0,0 @@
/******************************************************************************
* Copyright 2007 by Aaron Seigo <aseigo@kde.org> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; see the file COPYING.LIB. If not, write to *
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301, USA. *
*******************************************************************************/
#include "packagestructuretest.h"
#include <kconfig.h>
#include <kconfiggroup.h>
#include <QDebug>
#include <klocalizedstring.h>
#include "applet.h"
#include "packagestructure.h"
#include "pluginloader.h"
class NoPrefixes : public Plasma::Package
{
public:
explicit NoPrefixes()
: Plasma::Package(new Plasma::PackageStructure)
{
setContentsPrefixPaths(QStringList());
addDirectoryDefinition("bin", QStringLiteral("bin"), QStringLiteral("bin"));
addFileDefinition("MultiplePaths", QStringLiteral("first"), QStringLiteral("Description proper"));
addFileDefinition("MultiplePaths", QStringLiteral("second"), QStringLiteral("Description proper"));
setPath(QStringLiteral("/"));
}
};
void PackageStructureTest::initTestCase()
{
m_packagePath = QFINDTESTDATA("data/testpackage");
ps = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/Generic"));
ps.setPath(m_packagePath);
}
void PackageStructureTest::validStructures()
{
QVERIFY(ps.hasValidStructure());
QVERIFY(!Plasma::Package().hasValidStructure());
QVERIFY(!Plasma::PluginLoader::self()->loadPackage(QStringLiteral("doesNotExist")).hasValidStructure());
}
void PackageStructureTest::validPackages()
{
QVERIFY(ps.isValid());
QVERIFY(!Plasma::Package().isValid());
QVERIFY(!Plasma::PluginLoader::self()->loadPackage(QStringLiteral("doesNotExist")).isValid());
QVERIFY(NoPrefixes().isValid());
Plasma::Package p = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/Generic"));
QVERIFY(!p.isValid());
p.setPath(QStringLiteral("/does/not/exist"));
QVERIFY(!p.isValid());
p.setPath(ps.path());
QVERIFY(p.isValid());
}
void PackageStructureTest::copyPerformance()
{
// seed the cache first
ps.filePath("mainscript");
QBENCHMARK {
Plasma::Package foo(ps);
const QString bar = foo.filePath("mainscript");
Q_UNUSED(bar);
}
}
void PackageStructureTest::mutateAfterCopy()
{
const bool mainscriptRequired = ps.isRequired("mainscript");
const QStringList imageMimeTypes = ps.mimeTypes("images");
const QStringList defaultMimeTypes = ps.mimeTypes("translations");
const QString packageRoot = ps.defaultPackageRoot();
const bool externalPaths = ps.allowExternalPaths();
const QString servicePrefix = ps.servicePrefix();
const QStringList contentsPrefixPaths = ps.contentsPrefixPaths();
const QList<const char *> files = ps.files();
const QList<const char *> dirs = ps.directories();
Plasma::Package copy(ps);
copy.setRequired("mainscript", !mainscriptRequired);
QCOMPARE(ps.isRequired("mainscript"), mainscriptRequired);
QCOMPARE(copy.isRequired("mainscript"), !mainscriptRequired);
copy = ps;
const QString copyPackageRoot = packageRoot + "more/";
copy.setDefaultPackageRoot(copyPackageRoot);
QCOMPARE(ps.defaultPackageRoot(), packageRoot);
QCOMPARE(copy.defaultPackageRoot(), copyPackageRoot);
copy = ps;
copy.setAllowExternalPaths(!externalPaths);
QCOMPARE(ps.allowExternalPaths(), externalPaths);
QCOMPARE(copy.allowExternalPaths(), !externalPaths);
copy = ps;
const QString copyServicePrefix = packageRoot + "more/";
copy.setServicePrefix(copyServicePrefix);
QCOMPARE(ps.servicePrefix(), servicePrefix);
QCOMPARE(copy.servicePrefix(), copyServicePrefix);
copy = ps;
QStringList copyContentsPrefixPaths = contentsPrefixPaths;
copyContentsPrefixPaths << QStringLiteral("more/");
copy.setContentsPrefixPaths(copyContentsPrefixPaths);
QCOMPARE(ps.contentsPrefixPaths(), contentsPrefixPaths);
QCOMPARE(copy.contentsPrefixPaths(), copyContentsPrefixPaths);
copy = ps;
copy.addFileDefinition("nonsense", QStringLiteral("foobar"), QString());
QCOMPARE(ps.files(), files);
QVERIFY(ps.files() != copy.files());
copy = ps;
copy.addDirectoryDefinition("nonsense", QStringLiteral("foobar"), QString());
QCOMPARE(ps.directories(), dirs);
QVERIFY(ps.directories() != copy.directories());
copy = ps;
copy.removeDefinition("mainscript");
QCOMPARE(ps.files(), files);
QVERIFY(ps.files() != copy.files());
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
copy = ps;
QVERIFY(!imageMimeTypes.isEmpty());
QStringList copyMimeTypes;
copyMimeTypes << imageMimeTypes.first();
copy.setMimeTypes("images", copyMimeTypes);
QCOMPARE(ps.mimeTypes("images"), imageMimeTypes);
QCOMPARE(copy.mimeTypes("images"), copyMimeTypes);
copy = ps;
QStringList copyDefaultMimeTypes = defaultMimeTypes;
copyDefaultMimeTypes << QStringLiteral("rubbish");
copy.setDefaultMimeTypes(copyDefaultMimeTypes);
QCOMPARE(ps.mimeTypes("translations"), defaultMimeTypes);
QCOMPARE(copy.mimeTypes("translations"), copyDefaultMimeTypes);
#endif
}
void PackageStructureTest::emptyContentsPrefix()
{
NoPrefixes package;
QString path(package.filePath("bin", QStringLiteral("ls")));
//qDebug() << path;
QCOMPARE(path, QStringLiteral("/bin/ls"));
}
void PackageStructureTest::multiplePaths()
{
NoPrefixes package;
QCOMPARE(package.name("MultiplePaths"), QStringLiteral("Description proper"));
}
void PackageStructureTest::directories()
{
QList<const char *> dirs;
dirs << "config" << "data" << "images" << "theme" << "scripts" << "translations" << "ui";
QList<const char *> psDirs = ps.directories();
QCOMPARE(dirs.count(), psDirs.count());
foreach (const char *dir, psDirs) {
bool found = false;
foreach (const char *check, dirs) {
if (qstrcmp(dir, check)) {
found = true;
break;
}
}
QVERIFY(found);
}
foreach (const char *dir, dirs) {
bool found = false;
foreach (const char *check, psDirs) {
if (qstrcmp(dir, check)) {
found = true;
break;
}
}
QVERIFY(found);
}
}
void PackageStructureTest::requiredDirectories()
{
QList<const char *> dirs;
QCOMPARE(ps.requiredDirectories(), dirs);
}
void PackageStructureTest::files()
{
QList<const char *> files;
files << "mainconfigui" << "mainconfigxml" << "mainscript";
QList<const char *> psFiles = ps.files();
//for (int i = 0; i < psFiles.count(); ++i) {
// qDebug() << psFiles[i];
//}
foreach (const char *file, psFiles) {
bool found = false;
foreach (const char *check, files) {
if (qstrcmp(file, check)) {
found = true;
break;
}
}
QVERIFY(found);
}
}
void PackageStructureTest::requiredFiles()
{
QList<const char *> files;
files << "mainscript";
QList<const char *> psFiles = ps.requiredFiles();
QCOMPARE(files.count(), psFiles.count());
for (int i = 0; i < files.count(); ++i) {
QCOMPARE(files[i], psFiles[i]);
}
}
void PackageStructureTest::path()
{
QCOMPARE(ps.filePath("images"), QDir(m_packagePath + QStringLiteral("/contents/images")).canonicalPath());
QCOMPARE(ps.filePath("theme"), QDir(m_packagePath + QStringLiteral("/contents/theme")).canonicalPath());
QCOMPARE(ps.filePath("mainscript"), QFileInfo(m_packagePath + QStringLiteral("/contents/ui/main.qml")).canonicalFilePath());
}
void PackageStructureTest::name()
{
QCOMPARE(ps.name("config"), i18n("Configuration Definitions"));
QCOMPARE(ps.name("mainscript"), i18n("Main Script File"));
}
void PackageStructureTest::required()
{
QVERIFY(ps.isRequired("mainscript"));
}
void PackageStructureTest::mimeTypes()
{
QStringList mimeTypes;
mimeTypes << QStringLiteral("image/svg+xml") << QStringLiteral("image/png") << QStringLiteral("image/jpeg");
QCOMPARE(ps.mimeTypes("images"), mimeTypes);
QCOMPARE(ps.mimeTypes("theme"), mimeTypes);
}
QTEST_MAIN(PackageStructureTest)

View File

@ -1,53 +0,0 @@
/******************************************************************************
* Copyright 2007 by Aaron Seigo <aseigo@kde.org> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; see the file COPYING.LIB. If not, write to *
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301, USA. *
*******************************************************************************/
#ifndef PACKAGESTRUCTURETEST_H
#include <QtTest>
#include "plasma/package.h"
class PackageStructureTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void validStructures();
void validPackages();
void copyPerformance();
void mutateAfterCopy();
void emptyContentsPrefix();
void multiplePaths();
void directories();
void requiredDirectories();
void files();
void requiredFiles();
void path();
void name();
void required();
void mimeTypes();
private:
Plasma::Package ps;
QString m_packagePath;
};
#endif

View File

@ -1,99 +0,0 @@
/********************************************************************************
* Copyright 2010 by Martin Blumenstingl <darklight.xdarklight@googlemail.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; see the file COPYING.LIB. If not, write to *
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301, USA. *
*********************************************************************************/
#include "storagetest.h"
#include <QStandardPaths>
#include "plasma/private/storage_p.h"
void StorageTest::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
m_data.insert(QStringLiteral("String 1"), "Fork");
m_data.insert(QStringLiteral("String 2"), "Spoon");
m_data.insert(QStringLiteral("String 3"), "Knife");
m_data.insert(QStringLiteral("Int 1"), 3141);
m_data.insert(QStringLiteral("Int 2"), 60);
QByteArray bytes("yadda yadda yadda");
m_data.insert(QStringLiteral("Binary Data"), bytes);
}
void StorageTest::store()
{
Storage storage;
QVariantMap op = storage.operationDescription(QStringLiteral("save"));
op[QStringLiteral("group")] = "Test";
Plasma::ServiceJob *job = storage.startOperationCall(op);
StorageJob *storageJob = qobject_cast<StorageJob *>(job);
QVERIFY(storageJob);
if (storageJob) {
storageJob->setData(m_data);
QVERIFY(storageJob->exec());
QVERIFY(storageJob->result().toBool());
}
}
void StorageTest::retrieve()
{
Storage storage;
QVariantMap op = storage.operationDescription(QStringLiteral("retrieve"));
op[QStringLiteral("group")] = "Test";
Plasma::ServiceJob *job = storage.startOperationCall(op);
StorageJob *storageJob = qobject_cast<StorageJob *>(job);
QVERIFY(storageJob);
if (storageJob) {
QVERIFY(storageJob->exec());
QVERIFY(storageJob->result().type() != QVariant::Bool);
QCOMPARE(storageJob->data(), m_data);
}
}
void StorageTest::deleteEntry()
{
Storage storage;
QVariantMap op = storage.operationDescription(QStringLiteral("delete"));
op[QStringLiteral("group")] = "Test";
Plasma::ServiceJob *job = storage.startOperationCall(op);
StorageJob *storageJob = qobject_cast<StorageJob *>(job);
QVERIFY(storageJob);
if (storageJob) {
storageJob->setData(m_data);
QVERIFY(storageJob->exec());
QVERIFY(storageJob->result().toBool());
}
op = storage.operationDescription(QStringLiteral("retrieve"));
op[QStringLiteral("group")] = "Test";
job = storage.startOperationCall(op);
storageJob = qobject_cast<StorageJob *>(job);
QVERIFY(storageJob);
if (storageJob) {
QVERIFY(storageJob->exec());
QVERIFY(storageJob->result().type() != QVariant::Bool);
QVERIFY(storageJob->data().isEmpty());
}
}
QTEST_MAIN(StorageTest)

View File

@ -1,42 +0,0 @@
/********************************************************************************
* Copyright 2010 by Martin Blumenstingl <darklight.xdarklight@googlemail.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; see the file COPYING.LIB. If not, write to *
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301, USA. *
*********************************************************************************/
#ifndef STORAGETEST_H
#define STORAGETEST_H
#include <QtTest>
class StorageTest : public QObject
{
Q_OBJECT
public Q_SLOTS:
void initTestCase();
private Q_SLOTS:
void store();
void retrieve();
void deleteEntry();
private:
QVariantMap m_data;
};
#endif