[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepim-runtime] /: Remove it
From: Montel Laurent <montel () kde ! org>
Date: 2015-04-13 7:04:58
Message-ID: E1YhYQU-0007Za-W7 () scm ! kde ! org
[Download RAW message or body]
Git commit 6e6c49d3a7b3cbaaec051871e266ee5d78d85a77 by Montel Laurent.
Committed on 13/04/2015 at 07:04.
Pushed by mlaurent into branch 'master'.
Remove it
M +0 -1 CMakeLists.txt
D +0 -30 resourcetester/CMakeLists.txt
D +0 -1 resourcetester/autotests/CMakeLists.txt
D +0 -12 resourcetester/autotests/construct.es
D +0 -6 resourcetester/autotests/unittestenv/config-mysql-db.xml
D +0 -8 resourcetester/autotests/unittestenv/config.xml
D +- -- resourcetester/autotests/unittestenv/kdehome/share/apps/kwallet/kdewallet.kwl
D +0 -3 resourcetester/autotests/unittestenv/kdehome/share/config/akonadi-firstrunrc
D +0 -78 resourcetester/autotests/unittestenv/kdehome/share/config/kdebugrc
D +0 -3 resourcetester/autotests/unittestenv/kdehome/share/config/kdedrc
D +0 -8 resourcetester/autotests/unittestenv/kdehome/share/config/kwalletrc
D +0 -5 resourcetester/autotests/unittestenv/xdgconfig-mysql.db/akonadi/akonadiserverrc
D +0 -104 resourcetester/collectiontest.cpp
D +0 -53 resourcetester/collectiontest.h
D +0 -79 resourcetester/global.cpp
D +0 -37 resourcetester/global.h
D +0 -85 resourcetester/itemtest.cpp
D +0 -53 resourcetester/itemtest.h
D +0 -104 resourcetester/main.cpp
D +0 -212 resourcetester/qemu.cpp
D +0 -55 resourcetester/qemu.h
D +0 -166 resourcetester/resource.cpp
D +0 -60 resourcetester/resource.h
D +0 -69 resourcetester/script.cpp
D +0 -44 resourcetester/script.h
D +0 -46 resourcetester/system.cpp
D +0 -36 resourcetester/system.h
D +0 -83 resourcetester/test.cpp
D +0 -44 resourcetester/test.h
D +0 -22 resourcetester/wrappedobject.cpp
D +0 -40 resourcetester/wrappedobject.h
D +0 -450 resourcetester/xmloperations.cpp
D +0 -176 resourcetester/xmloperations.h
http://commits.kde.org/kdepim-runtime/6e6c49d3a7b3cbaaec051871e266ee5d78d85a77
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6927b78..7d0297d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -145,7 +145,6 @@ add_subdirectory(resources)
add_subdirectory(agents)
add_subdirectory(plugins)
add_subdirectory(defaultsetup)
-add_subdirectory(resourcetester)
add_subdirectory(kioslave)
add_subdirectory(kcm)
add_subdirectory(migration)
diff --git a/resourcetester/CMakeLists.txt b/resourcetester/CMakeLists.txt
deleted file mode 100644
index ec81d76..0000000
--- a/resourcetester/CMakeLists.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY)
-
-add_subdirectory( autotests )
-
-set( resourcetester_SRCS
- global.cpp
- main.cpp
- resource.cpp
- script.cpp
- test.cpp
- xmloperations.cpp
- collectiontest.cpp
- itemtest.cpp
- qemu.cpp
- system.cpp
- wrappedobject.cpp
-)
-
-add_executable(resourcetester ${resourcetester_SRCS})
-
-target_link_libraries( resourcetester
- KF5::AkonadiXml
- KF5::AkonadiCore
- Qt5::Test
- KF5::KrossCore
- KF5::KIOCore
-)
-
diff --git a/resourcetester/autotests/CMakeLists.txt \
b/resourcetester/autotests/CMakeLists.txt deleted file mode 100644
index 9c7d9f4..0000000
--- a/resourcetester/autotests/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-akonadi_add_resourcetest( ctor-test construct.es )
diff --git a/resourcetester/autotests/construct.es \
b/resourcetester/autotests/construct.es deleted file mode 100644
index 335aadd..0000000
--- a/resourcetester/autotests/construct.es
+++ /dev/null
@@ -1,12 +0,0 @@
-var i1 = ItemTest.newInstance();
-var i2 = ItemTest.newInstance();
-
-print( i1 );
-print( i2 );
-
-i1.setMimeType( "application/foo" );
-i2.setMimeType( "application/bar" );
-
-print( i1.mimeType() + " != " + i2.mimeType() );
-Test.verify( i1.mimeType() != i2.mimeType() );
-
diff --git a/resourcetester/autotests/unittestenv/config-mysql-db.xml \
b/resourcetester/autotests/unittestenv/config-mysql-db.xml deleted file mode 100644
index 44ae937..0000000
--- a/resourcetester/autotests/unittestenv/config-mysql-db.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<config>
- <kdehome>kdehome</kdehome>
- <confighome>xdgconfig-mysql.db</confighome>
- <datahome>xdglocal</datahome>
- <envvar name="AKONADI_DISABLE_AGENT_AUTOSTART">true</envvar>
-</config>
diff --git a/resourcetester/autotests/unittestenv/config.xml \
b/resourcetester/autotests/unittestenv/config.xml deleted file mode 100644
index 0b5ea9c..0000000
--- a/resourcetester/autotests/unittestenv/config.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<config>
- <kdehome>kdehome</kdehome>
- <confighome>xdgconfig</confighome>
- <datahome>xdglocal</datahome>
- <agent synchronize="true">akonadi_knut_resource</agent>
- <agent synchronize="true">akonadi_knut_resource</agent>
- <agent synchronize="true">akonadi_knut_resource</agent>
-</config>
diff --git a/resourcetester/autotests/unittestenv/kdehome/share/apps/kwallet/kdewallet.kwl \
b/resourcetester/autotests/unittestenv/kdehome/share/apps/kwallet/kdewallet.kwl \
deleted file mode 100644 index dfb4fd6..0000000
Binary files a/resourcetester/autotests/unittestenv/kdehome/share/apps/kwallet/kdewallet.kwl \
and /dev/null differ
diff --git a/resourcetester/autotests/unittestenv/kdehome/share/config/akonadi-firstrunrc \
b/resourcetester/autotests/unittestenv/kdehome/share/config/akonadi-firstrunrc \
deleted file mode 100644 index 1cac492..0000000
--- a/resourcetester/autotests/unittestenv/kdehome/share/config/akonadi-firstrunrc
+++ /dev/null
@@ -1,3 +0,0 @@
-[ProcessedDefaults]
-defaultaddressbook=done
-defaultcalendar=done
diff --git a/resourcetester/autotests/unittestenv/kdehome/share/config/kdebugrc \
b/resourcetester/autotests/unittestenv/kdehome/share/config/kdebugrc deleted file \
mode 100755 index 5cc0a64..0000000
--- a/resourcetester/autotests/unittestenv/kdehome/share/config/kdebugrc
+++ /dev/null
@@ -1,78 +0,0 @@
-[0]
-AbortFatal=true
-ErrorFilename[$e]=kdebug.dbg
-ErrorOutput=2
-FatalFilename[$e]=kdebug.dbg
-FatalOutput=2
-InfoFilename[$e]=kdebug.dbg
-InfoOutput=2
-WarnFilename[$e]=kdebug.dbg
-WarnOutput=2
-
-[264]
-AbortFatal=true
-ErrorFilename[$e]=kdebug.dbg
-ErrorOutput=4
-FatalFilename[$e]=kdebug.dbg
-FatalOutput=4
-InfoFilename[$e]=kdebug.dbg
-WarnFilename[$e]=kdebug.dbg
-WarnOutput=4
-
-[5250]
-InfoOutput=2
-
-[7009]
-AbortFatal=true
-ErrorFilename[$e]=kdebug.dbg
-ErrorOutput=4
-FatalFilename[$e]=kdebug.dbg
-FatalOutput=4
-InfoFilename[$e]=kdebug.dbg
-InfoOutput=4
-WarnFilename[$e]=kdebug.dbg
-WarnOutput=4
-
-[7011]
-AbortFatal=true
-ErrorFilename[$e]=kdebug.dbg
-ErrorOutput=4
-FatalFilename[$e]=kdebug.dbg
-FatalOutput=4
-InfoFilename[$e]=kdebug.dbg
-InfoOutput=4
-WarnFilename[$e]=kdebug.dbg
-WarnOutput=4
-
-[7012]
-AbortFatal=true
-ErrorFilename[$e]=kdebug.dbg
-ErrorOutput=4
-FatalFilename[$e]=kdebug.dbg
-FatalOutput=4
-InfoFilename[$e]=kdebug.dbg
-InfoOutput=4
-WarnFilename[$e]=kdebug.dbg
-WarnOutput=4
-
-[7014]
-AbortFatal=true
-ErrorFilename[$e]=kdebug.dbg
-ErrorOutput=0
-FatalFilename[$e]=kdebug.dbg
-FatalOutput=0
-InfoFilename[$e]=kdebug.dbg
-InfoOutput=0
-WarnFilename[$e]=kdebug.dbg
-WarnOutput=0
-
-[7021]
-AbortFatal=true
-ErrorFilename[$e]=kdebug.dbg
-ErrorOutput=4
-FatalFilename[$e]=kdebug.dbg
-FatalOutput=4
-InfoFilename[$e]=kdebug.dbg
-InfoOutput=4
-WarnFilename[$e]=kdebug.dbg
-WarnOutput=4
diff --git a/resourcetester/autotests/unittestenv/kdehome/share/config/kdedrc \
b/resourcetester/autotests/unittestenv/kdehome/share/config/kdedrc deleted file mode \
100644 index 41d1781..0000000
--- a/resourcetester/autotests/unittestenv/kdehome/share/config/kdedrc
+++ /dev/null
@@ -1,3 +0,0 @@
-[General]
-CheckSycoca=false
-CheckFileStamps=false
diff --git a/resourcetester/autotests/unittestenv/kdehome/share/config/kwalletrc \
b/resourcetester/autotests/unittestenv/kdehome/share/config/kwalletrc deleted file \
mode 100644 index d063aeb..0000000
--- a/resourcetester/autotests/unittestenv/kdehome/share/config/kwalletrc
+++ /dev/null
@@ -1,8 +0,0 @@
-[Auto Allow]
-kdewallet=Akonadi Resource
-
-[Wallet]
-Close When Idle=false
-Enabled=true
-First Use=false
-Use One Wallet=true
diff --git a/resourcetester/autotests/unittestenv/xdgconfig-mysql.db/akonadi/akonadiserverrc \
b/resourcetester/autotests/unittestenv/xdgconfig-mysql.db/akonadi/akonadiserverrc \
deleted file mode 100644 index fa9b2d4..0000000
--- a/resourcetester/autotests/unittestenv/xdgconfig-mysql.db/akonadi/akonadiserverrc
+++ /dev/null
@@ -1,5 +0,0 @@
-[%General]
-ExternalPayload=false
-
-[Search]
-Manager=Dummy
diff --git a/resourcetester/collectiontest.cpp b/resourcetester/collectiontest.cpp
deleted file mode 100644
index 476a890..0000000
--- a/resourcetester/collectiontest.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- Copyright (c) 2009 Volker Krause <vkrause@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 "collectiontest.h"
-#include "test.h"
-
-#include <AkonadiCore/collectioncreatejob.h>
-#include <AkonadiCore/collectionmodifyjob.h>
-#include <AkonadiCore/collectiondeletejob.h>
-#include <AkonadiCore/collectionpathresolver.h>
-
-#include <QStringList>
-
-using namespace Akonadi;
-
-CollectionTest::CollectionTest(QObject *parent) :
- QObject(parent)
-{
-}
-
-void CollectionTest::setParent(const Akonadi::Collection &parent)
-{
- mParent = parent;
-}
-
-void CollectionTest::setCollection(const Akonadi::Collection &collection)
-{
- mCollection = collection;
-}
-
-void CollectionTest::setParent(const QString &parentPath)
-{
- CollectionPathResolver *resolver = new CollectionPathResolver(parentPath, this);
- if (!resolver->exec()) {
- Test::instance()->fail(resolver->errorString());
- }
- setParent(Collection(resolver->collection()));
-}
-
-void CollectionTest::setCollection(const QString &path)
-{
- CollectionPathResolver *resolver = new CollectionPathResolver(path, this);
- if (!resolver->exec()) {
- Test::instance()->fail(resolver->errorString());
- }
- setCollection(Collection(resolver->collection()));
-}
-
-void CollectionTest::setName(const QString &name)
-{
- mCollection.setName(name);
-}
-
-void CollectionTest::addContentType(const QString &type)
-{
- mCollection.setContentMimeTypes(mCollection.contentMimeTypes() << type);
-}
-
-void CollectionTest::create()
-{
- mCollection.setParentCollection(mParent);
- CollectionCreateJob *job = new CollectionCreateJob(mCollection, this);
- if (!job->exec()) {
- Test::instance()->fail(job->errorString());
- }
-}
-
-void CollectionTest::update()
-{
- CollectionModifyJob *job = new CollectionModifyJob(mCollection, this);
- if (!job->exec()) {
- Test::instance()->fail(job->errorString());
- }
-}
-
-void CollectionTest::remove()
-{
- CollectionDeleteJob *job = new CollectionDeleteJob(mCollection, this);
- if (!job->exec()) {
- Test::instance()->fail(job->errorString());
- }
-}
-
-QObject *CollectionTest::newInstance()
-{
- return createNewInstance<CollectionTest>(this);
-}
-
diff --git a/resourcetester/collectiontest.h b/resourcetester/collectiontest.h
deleted file mode 100644
index dac5dfe..0000000
--- a/resourcetester/collectiontest.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- Copyright (c) 2009 Volker Krause <vkrause@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 COLLECTIONTEST_H
-#define COLLECTIONTEST_H
-
-#include "wrappedobject.h"
-
-#include <AkonadiCore/collection.h>
-
-class CollectionTest : public QObject, protected WrappedObject
-{
- Q_OBJECT
-public:
- explicit CollectionTest(QObject *parent = Q_NULLPTR);
-
- void setParent(const Akonadi::Collection &parent);
- void setCollection(const Akonadi::Collection &collection);
-
-public slots:
- QObject *newInstance();
-
- void setParent(const QString &parentPath);
- void setCollection(const QString &path);
- void setName(const QString &name);
- void addContentType(const QString &type);
-
- void create();
- void update();
- void remove();
-
-private:
- Akonadi::Collection mParent;
- Akonadi::Collection mCollection;
-};
-
-#endif
diff --git a/resourcetester/global.cpp b/resourcetester/global.cpp
deleted file mode 100644
index 7280a4c..0000000
--- a/resourcetester/global.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2009 Volker Krause <vkrause@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "global.h"
-
-#include <QDir>
-#include <kstandarddirs.h>
-#include <QDebug>
-
-class GlobalPrivate
-{
-public:
- GlobalPrivate() : parent(new QObject()) {}
- QString basePath;
- QString vmPath;
- QObject *parent;
-};
-
-Q_GLOBAL_STATIC(GlobalPrivate, sInstance)
-
-QString Global::basePath()
-{
- return sInstance->basePath;
-}
-
-void Global::setBasePath(const QString &path)
-{
- sInstance->basePath = path;
- if (!path.endsWith(QDir::separator())) {
- sInstance->basePath += QDir::separator();
- }
-}
-
-QString Global::vmPath()
-{
- if (sInstance->vmPath.isEmpty()) {
- setVMPath(KStandardDirs::locateLocal("cache", "akonadi-resourcetester/", \
true));
- }
- return sInstance->vmPath;
-}
-
-void Global::setVMPath(const QString &path)
-{
- qDebug() << path;
- sInstance->vmPath = path;
- if (!path.endsWith(QDir::separator())) {
- sInstance->vmPath += QDir::separator();
- }
- const QDir dir(path);
- if (!dir.exists()) {
- QDir::root().mkpath(path);
- }
-}
-
-QObject *Global::parent()
-{
- Q_ASSERT(sInstance->parent);
- return sInstance->parent;
-}
-
-void Global::cleanup()
-{
- delete sInstance->parent;
- sInstance->parent = 0;
-}
diff --git a/resourcetester/global.h b/resourcetester/global.h
deleted file mode 100644
index 849feff..0000000
--- a/resourcetester/global.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2009 Volker Krause <vkrause@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GLOBAL_H
-#define GLOBAL_H
-
-#include <QString>
-
-class QObject;
-
-namespace Global
-{
-QString basePath();
-void setBasePath(const QString &path);
-
-QString vmPath();
-void setVMPath(const QString &path);
-
-QObject *parent();
-void cleanup();
-}
-
-#endif
diff --git a/resourcetester/itemtest.cpp b/resourcetester/itemtest.cpp
deleted file mode 100644
index c3a057e..0000000
--- a/resourcetester/itemtest.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- Copyright (c) 2009 Volker Krause <vkrause@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 "itemtest.h"
-
-#include "global.h"
-#include "test.h"
-
-#include <AkonadiCore/collectionpathresolver.h>
-#include <AkonadiCore/itemcreatejob.h>
-
-#include <QDebug>
-#include <QFile>
-
-using namespace Akonadi;
-
-ItemTest::ItemTest(QObject *parent) :
- QObject(parent)
-{
- setObjectName("global");
-}
-
-void ItemTest::setParentCollection(const Akonadi::Collection &parent)
-{
- mParent = parent;
-}
-
-void ItemTest::setParentCollection(const QString &path)
-{
- CollectionPathResolver *resolver = new CollectionPathResolver(path, this);
- if (!resolver->exec()) {
- Test::instance()->fail(resolver->errorString());
- }
- setParentCollection(Collection(resolver->collection()));
-}
-
-QString ItemTest::mimeType() const
-{
- return mItem.mimeType();
-}
-
-void ItemTest::setMimeType(const QString &mimeType)
-{
- mItem.setMimeType(mimeType);
-}
-
-void ItemTest::setPayloadFromFile(const QString &fileName)
-{
- QFile file(Global::basePath() + fileName);
- if (!file.open(QFile::ReadOnly)) {
- Test::instance()->fail(file.errorString());
- }
- mItem.setPayloadFromData(file.readAll());
-}
-
-void ItemTest::create()
-{
- ItemCreateJob *job = new ItemCreateJob(mItem, mParent, this);
- if (!job->exec()) {
- Test::instance()->fail(job->errorString());
- }
- mItem = job->item();
-}
-
-QObject *ItemTest::newInstance()
-{
- return createNewInstance<ItemTest>(this);
-}
-
diff --git a/resourcetester/itemtest.h b/resourcetester/itemtest.h
deleted file mode 100644
index 3f739fe..0000000
--- a/resourcetester/itemtest.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- Copyright (c) 2009 Volker Krause <vkrause@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 ITEMTEST_H
-#define ITEMTEST_H
-
-#include "wrappedobject.h"
-
-#include <AkonadiCore/collection.h>
-#include <AkonadiCore/item.h>
-
-class ItemTest : public QObject, protected WrappedObject
-{
- Q_OBJECT
-public:
- explicit ItemTest(QObject *parent = Q_NULLPTR);
-
- void setParentCollection(const Akonadi::Collection &parent);
-
-public slots:
- QObject *newInstance();
-
- void setParentCollection(const QString &path);
- QString mimeType() const;
- void setMimeType(const QString &mimeType);
- void setPayloadFromFile(const QString &fileName);
-
- void create();
-
-private:
- Akonadi::Collection mParent;
- Akonadi::Item mItem;
-};
-
-Q_DECLARE_METATYPE(ItemTest *)
-
-#endif
diff --git a/resourcetester/main.cpp b/resourcetester/main.cpp
deleted file mode 100644
index 08500c8..0000000
--- a/resourcetester/main.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2009 Igor Trindade Oliveira <igor_trindade@yahoo.com.br>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resource.h"
-#include "script.h"
-#include "xmloperations.h"
-#include "global.h"
-#include "test.h"
-#include "collectiontest.h"
-#include "itemtest.h"
-#include "system.h"
-#include "qemu.h"
-
-#include <AkonadiCore/control.h>
-
-#include <KAboutData>
-
-#include <QDebug>
-
-#include <QCoreApplication>
-#include <QtCore/QTimer>
-#include <QFileInfo>
-
-#include <signal.h>
-#include <QApplication>
-#include <KLocalizedString>
-#include <QCommandLineParser>
-#include <QCommandLineOption>
-
-void sigHandler(int signal)
-{
- Q_UNUSED(signal);
- QCoreApplication::quit();
-}
-
-int main(int argc, char *argv[])
-{
- QString path;
-
- KAboutData aboutData(QLatin1String("akonadi-RT"),
- i18n("Akonadi Resource Tester"),
- QLatin1String("1.0"),
- i18n("Resource Tester"),
- KAboutLicense::GPL,
- i18n("(c) 2009 Igor Trindade Oliveira"));
-
- QApplication app(argc, argv);
- QCommandLineParser parser;
- KAboutData::setApplicationData(aboutData);
- parser.addVersionOption();
- parser.addHelpOption();
- parser.addOption(QCommandLineOption(QStringList() << QLatin1String("c") << \
QLatin1String("config"), i18n("Configuration file to open"), \
QLatin1String("configfile"), QLatin1String("script.js/py/rb")));
-
- //PORTING SCRIPT: adapt aboutdata variable if necessary
- aboutData.setupCommandLine(&parser);
- parser.process(app);
- aboutData.processCommandLine(&parser);
-
- if (parser.isSet(QLatin1String("config"))) {
- path.append(parser.value(QLatin1String("config"))) ;
- } else {
- return -1;
- }
- Global::setBasePath(QFileInfo(path).absolutePath());
-
-#ifdef Q_OS_UNIX
- signal(SIGINT, sigHandler);
- signal(SIGQUIT, sigHandler);
-#endif
-
- if (!Akonadi::Control::start()) {
- qFatal("Unable to start Akonadi!");
- }
-
- Script *script = new Script();
-
- script->configure(path);
- script->insertObject(new XmlOperations(Global::parent()), "XmlOperations");
- script->insertObject(new Resource(Global::parent()), "Resource");
- script->insertObject(Test::instance(), "Test");
- script->insertObject(new CollectionTest(Global::parent()), "CollectionTest");
- script->insertObject(new ItemTest(Global::parent()), "ItemTest");
- script->insertObject(new System(Global::parent()), "System");
- script->insertObject(new QEmu(Global::parent()), "QEmu");
- QTimer::singleShot(0, script, SLOT(start()));
-
- const int result = app.exec();
- Global::cleanup();
- return result;
-}
diff --git a/resourcetester/qemu.cpp b/resourcetester/qemu.cpp
deleted file mode 100644
index f6ea1a5..0000000
--- a/resourcetester/qemu.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- Copyright (c) 2009 Volker Krause <vkrause@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 "qemu.h"
-
-#include "global.h"
-#include "test.h"
-
-#include <KConfig>
-#include <QDebug>
-#include <KConfigGroup>
-#include <KShell>
-#include <KIO/NetAccess>
-#include <qtest.h>
-#include <QUrl>
-
-#include <QDir>
-#include <QFile>
-#include <QTcpSocket>
-
-QEmu::QEmu(QObject *parent) :
- QObject(parent),
- mVMConfig(0),
- mVMProcess(0),
- mPortOffset(42000), // TODO should be somewhat dynamic to allo running \
multiple instances in parallel
- mMonitorPort(-1),
- mStarted(false)
-{
- Q_ASSERT(parent);
-}
-
-QEmu::~QEmu()
-{
- if (mVMProcess && mVMProcess->state() == QProcess::Running) {
- stop();
- }
- delete mVMConfig;
-}
-
-void QEmu::setVMConfig(const QString &configFileName)
-{
- delete mVMConfig;
- mVMConfig = new KConfig(Global::basePath() + QLatin1Char('/') + configFileName);
-}
-
-void QEmu::start()
-{
- Q_ASSERT(mVMConfig);
- if (mVMProcess) {
- qWarning() << "VM already running.";
- return;
- }
-
- KConfigGroup emuConf(mVMConfig, "Emulator");
- QStringList args = KShell::splitArgs(emuConf.readEntry("Arguments", QString()));
- const QList<int> ports = emuConf.readEntry("Ports", QList<int>());
- foreach (int port, ports) {
- args << "-redir" << QString::fromLatin1("tcp:%1::%2").arg(port + \
mPortOffset).arg(port);
- }
- mMonitorPort = emuConf.readEntry("MonitorPort", 23) + mPortOffset;
- args << "-monitor" << \
QString::fromLatin1("tcp:127.0.0.1:%1,server,nowait").arg(mMonitorPort);
- args << "-hda" << vmImage();
-
- // If a SnapshotName is given in the configuration, load that snapshot
- // with -loadvm and assume that it's OK to write to he image file.
- // Othewise, use the -snapshot option to avoid changing the image
- // file.
- QString snapshotName = emuConf.readEntry("SnapshotName", "");
- if (snapshotName.isEmpty()) {
- args << "-snapshot";
- } else {
- args << "-loadvm" << snapshotName;
- }
-
- qDebug() << "Starting QEMU with arguments" << args << "...";
-
- mVMProcess = new KProcess(this);
- connect(mVMProcess, SIGNAL(finished(int,QProcess::ExitStatus)), \
SLOT(vmFinished(int,QProcess::ExitStatus)));
- mVMProcess->setProgram("qemu", args);
- mVMProcess->start();
- mVMProcess->waitForStarted();
- mStarted = true;
- qDebug() << "QEMU started.";
-
- if (emuConf.readEntry("WaitForPorts", true)) {
- const QList<int> waitPorts = emuConf.readEntry("WaitForPorts", \
QList<int>());
- foreach (int port, waitPorts) {
- waitForPort(port);
- }
- }
-}
-
-void QEmu::stop()
-{
- mStarted = false;
- if (!mVMProcess) {
- return;
- }
- qDebug() << "Stopping QEMU...";
-
- // send stop command via QEMU monitor
- QTcpSocket socket;
- socket.connectToHost("localhost", mMonitorPort);
- if (socket.waitForConnected()) {
- socket.write("quit\n");
- socket.flush();
- socket.waitForBytesWritten();
- mVMProcess->waitForFinished(10000);
- } else {
- qDebug() << "Unable to connect to QEMU monitor:" << socket.errorString();
- }
-
- if (mVMProcess->state() == QProcess::Running) {
- qDebug() << "qemu is still running. terminating";
- mVMProcess->terminate();
- }
-
- delete mVMProcess;
- mVMProcess = 0;
- qDebug() << "QEMU stopped.";
-}
-
-QString QEmu::vmImage() const
-{
- KConfigGroup conf(mVMConfig, "Image");
-
- const QUrl imageUrl = QUrl::fromLocalFile(conf.readEntry("Source", QString()));
- Q_ASSERT(!imageUrl.isEmpty());
-
- const QString imageArchiveFileName = imageUrl.fileName();
- Q_ASSERT(!imageArchiveFileName.isEmpty());
-
- // check if the image has been downloaded already
- const QString localArchiveFileName = Global::vmPath() + imageArchiveFileName;
- if (!QFile::exists(localArchiveFileName)) {
- qDebug() << "Downloading VM image from" << imageUrl << "to" << \
localArchiveFileName << "...";
- const bool result = KIO::NetAccess::file_copy(imageUrl, \
QUrl::fromLocalFile(localArchiveFileName), 0);
- if (!result) {
- qCritical() << "Downloading" << imageUrl << "failed!";
- }
- qDebug() << "Downloading VM image complete.";
- }
-
- // check if the image archive has been extracted yet
- const QString extractedDirName = Global::vmPath() + imageArchiveFileName + \
".directory";
- if (!QDir::root().exists(extractedDirName)) {
- qDebug() << "Extracting VM image...";
- QDir::root().mkpath(extractedDirName);
- KProcess proc;
- proc.setWorkingDirectory(extractedDirName);
- proc.setProgram("tar", QStringList() << "xvf" << localArchiveFileName);
- proc.execute();
- qDebug() << "Extracting VM image complete.";
- }
-
- // check if the actual image file is there and return it
- const QString imageFile = extractedDirName + QDir::separator() + \
conf.readEntry("File", QString());
- if (!QFile::exists(imageFile)) {
- qCritical() << "Image file" << imageFile << "does not exist.";
- }
-
- return imageFile;
-}
-
-void QEmu::waitForPort(int port)
-{
- qDebug() << "Waiting for port" << (port + mPortOffset) << "...";
- forever {
- QTcpSocket socket;
- socket.connectToHost("localhost", port + mPortOffset);
- if (!socket.waitForConnected(5000))
- {
- QTest::qWait(5000);
- continue;
- }
- if (socket.waitForReadyRead(5000))
- {
- break;
- }
- }
-}
-
-int QEmu::portOffset() const
-{
- return mPortOffset;
-}
-
-void QEmu::vmFinished(int exitCode, QProcess::ExitStatus exitStatus)
-{
- Q_UNUSED(exitCode);
- Q_UNUSED(exitStatus);
- if (mStarted) {
- Test::instance()->fail("QEMU termineated!");
- }
-}
-
diff --git a/resourcetester/qemu.h b/resourcetester/qemu.h
deleted file mode 100644
index 59df688..0000000
--- a/resourcetester/qemu.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- Copyright (c) 2009 Volker Krause <vkrause@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 QEMU_H
-#define QEMU_H
-
-#include <KProcess>
-
-class KConfig;
-
-class QEmu : public QObject
-{
- Q_OBJECT
-public:
- explicit QEmu(QObject *parent);
- ~QEmu();
-
-public slots:
- void setVMConfig(const QString &configFileName);
- void start();
- void stop();
- int portOffset() const;
-
-private:
- QString vmImage() const;
- void waitForPort(int port);
-
-private slots:
- void vmFinished(int exitCode, QProcess::ExitStatus exitStatus);
-
-private:
- KConfig *mVMConfig;
- KProcess *mVMProcess;
- int mPortOffset;
- int mMonitorPort;
- bool mStarted;
-};
-
-#endif
diff --git a/resourcetester/resource.cpp b/resourcetester/resource.cpp
deleted file mode 100644
index 53f7be1..0000000
--- a/resourcetester/resource.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (c) 2009 Igor Trindade Oliveira <igor_trindade@yahoo.com.br>
- * Copyright (c) 2009 Volker Krause <vkrause@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resource.h"
-
-#include "global.h"
-#include <AkonadiCore/resourcesynchronizationjob.h>
-#include "test.h"
-
-#include <AkonadiCore/agentmanager.h>
-#include <AkonadiCore/agentinstancecreatejob.h>
-
-#include <QDebug>
-#include <qtest.h>
-
-#include <QDBusConnection>
-#include <QDBusInterface>
-#include <QDBusReply>
-#include <QFileInfo>
-#include <QDir>
-
-using namespace Akonadi;
-
-Resource::Resource(QObject *parent) :
- QObject(parent)
-{
- Q_ASSERT(parent);
-}
-
-Resource::~Resource()
-{
- destroy();
-}
-
-void Resource::setType(const QString &type)
-{
- mTypeIdentifier = type;
-}
-
-QString Resource::identifier() const
-{
- return mInstance.identifier();
-}
-
-void Resource::setOption(const QString &key, const QVariant &value)
-{
- mSettings.insert(key, value);
-}
-
-void Resource::setPathOption(const QString &key, const QString &path)
-{
- if (QFileInfo(path).isAbsolute()) {
- setOption(key, path);
- } else {
- setOption(key, QString(Global::basePath() + QDir::separator() + path));
- }
-}
-
-bool Resource::createResource()
-{
- if (mInstance.isValid()) {
- return false;
- }
-
- const AgentType type = AgentManager::self()->type(mTypeIdentifier);
- if (!type.isValid()) {
- return false;
- }
-
- AgentInstanceCreateJob *job = new AgentInstanceCreateJob(type, this);
- if (!job->exec()) {
- qWarning() << job->errorText();
- return false;
- }
- mInstance = job->instance();
-
- QDBusInterface iface("org.freedesktop.Akonadi.Resource." + identifier(), \
"/Settings");
- if (!iface.isValid()) {
- return false;
- }
-
- // configure resource
- for (QHash<QString, QVariant>::const_iterator it = mSettings.constBegin(); it != \
mSettings.constEnd(); ++it) {
- qDebug() << "Setting up " << it.key() << " for agent " << identifier();
- const QString methodName = QStringLiteral("set%1").arg(it.key());
- const QVariant arg = it.value();
- QDBusReply<void> reply = iface.call(methodName, arg);
- if (!reply.isValid()) {
- qCritical() << "Setting " << it.key() << " failed for agent " << \
identifier() << ":" << reply.error().message();
- }
- }
- mInstance.reconfigure();
-
- ResourceSynchronizationJob *syncJob = new ResourceSynchronizationJob(mInstance, \
this);
- if (!syncJob->exec()) {
- qCritical() << "Synching resource failed: " << syncJob->errorString();
- }
-
- return true;
-}
-
-void Resource::create()
-{
- if (!createResource()) {
- Test::instance()->fail("Creating resource failed.");
- }
-}
-
-void Resource::destroy()
-{
- if (!mInstance.isValid()) {
- return;
- }
- AgentManager::self()->removeInstance(mInstance);
- mInstance = AgentInstance();
-}
-
-void Resource::write()
-{
- QDBusInterface iface("org.freedesktop.Akonadi", "/notifications/debug", \
"org.freedesktop.Akonadi.NotificationManager");
- Q_ASSERT(iface.isValid());
- QDBusReply<void> result = iface.call("emitPendingNotifications");
- if (!result.isValid()) {
- Test::instance()->fail(result.error().message());
- }
- ResourceSynchronizationJob *syncJob = new ResourceSynchronizationJob(mInstance, \
this);
- if (!syncJob->exec()) {
- qCritical() << "Synching resource failed: " << syncJob->errorString();
- }
-}
-
-void Resource::recreate()
-{
- write();
- destroy();
- create();
-}
-
-QObject *Resource::newInstance()
-{
- return createNewInstance<Resource>(this);
-}
-
-QObject *Resource::newInstance(const QString &type)
-{
- Resource *r = qobject_cast<Resource *>(createNewInstance<Resource>(this));
- Q_ASSERT(r);
- r->setType(type);
- return r;
-}
-
diff --git a/resourcetester/resource.h b/resourcetester/resource.h
deleted file mode 100644
index e1544ef..0000000
--- a/resourcetester/resource.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- Copyright (c) 2009 Volker Krause <vkrause@kde.org>
- Copyright (c) 2009 Igor Trindade Oliveira <igor_trindade@yahoo.com.br>
-
- 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 RESOURCE_H
-#define RESOURCE_H
-
-#include "wrappedobject.h"
-#include <AkonadiCore/agentinstance.h>
-
-#include <QHash>
-#include <QPointer>
-#include <QVariant>
-
-class Resource: public QObject, protected WrappedObject
-{
- Q_OBJECT
-public:
- explicit Resource(QObject *parent);
- ~Resource();
-
-public slots:
- QObject *newInstance();
- QObject *newInstance(const QString &type);
-
- void setType(const QString &type);
- QString identifier() const;
-
- void setOption(const QString &key, const QVariant &value);
- void setPathOption(const QString &key, const QString &path);
-
- bool createResource();
- void create();
- void destroy();
- void write();
- void recreate();
-
-private:
- QString mTypeIdentifier;
- Akonadi::AgentInstance mInstance;
- QHash<QString, QVariant> mSettings;
-};
-
-#endif
diff --git a/resourcetester/script.cpp b/resourcetester/script.cpp
deleted file mode 100644
index 0957323..0000000
--- a/resourcetester/script.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2009 Igor Trindade Oliveira <igor_trindade@yahoo.com.br>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "script.h"
-#include "global.h"
-#include <QDebug>
-#include <qcoreapplication.h>
-
-Script::Script()
-{
- action = new Kross::Action(this, "ResourceTester");
- connect(action, &Kross::Action::finished, this, &Script::finished);
- action->addObject(this, QStringLiteral("Script"));
-}
-
-void Script::configure(const QString &path)
-{
- action->setFile(path);
-}
-
-void Script::insertObject(QObject *object, const QString &objectName)
-{
- action->addObject(object, objectName);
-}
-
-void Script::include(const QString &path)
-{
- QFile f(Global::basePath() + path);
- if (!f.open(QFile::ReadOnly)) {
- qCritical() << "Unable to open file" << Global::basePath() + path;
- } else {
- action->evaluate(f.readAll());
- }
-}
-
-QString Script::absoluteFileName(const QString &path)
-{
- return Global::basePath() + path;
-}
-
-void Script::start()
-{
- action->trigger();
-}
-
-void Script::finished(Kross::Action *action)
-{
- if (action->hadError()) {
- qCritical() << action->errorMessage() << action->errorTrace();
- QCoreApplication::instance()->exit(1);
- } else {
- QCoreApplication::instance()->quit();
- }
-}
-
diff --git a/resourcetester/script.h b/resourcetester/script.h
deleted file mode 100644
index 92bbcf2..0000000
--- a/resourcetester/script.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2009 Igor Trindade Oliveira <igor_trindade@yahoo.com.br>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef SCRIPT_H
-#define SCRIPT_H
-
-#include <kross/core/action.h>
-#include <QHash>
-
-class Script : public QObject
-{
- Q_OBJECT
-public:
- Script();
- void configure(const QString &path);
- void insertObject(QObject *object, const QString &objectName);
-
-public slots:
- Q_SCRIPTABLE void include(const QString &path);
- Q_SCRIPTABLE QString absoluteFileName(const QString &path);
-
-private slots:
- void start();
- void finished(Kross::Action *action);
-
-private:
- Kross::Action *action;
-};
-
-#endif
diff --git a/resourcetester/system.cpp b/resourcetester/system.cpp
deleted file mode 100644
index 09f2261..0000000
--- a/resourcetester/system.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- Copyright (c) 2009 Volker Krause <vkrause@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 "system.h"
-#include "test.h"
-#include "global.h"
-
-#include <KProcess>
-#include <QFile>
-#include <qtest.h>
-
-System::System(QObject *parent) :
- QObject(parent)
-{
-}
-
-void System::exec(const QString &_program, const QStringList &args)
-{
- QString program = _program;
- if (QFile::exists(Global::basePath() + _program)) {
- program = Global::basePath() + _program;
- }
- Test::instance()->verify(KProcess::execute(program, args) == 0);
-}
-
-void System::sleep(int secs)
-{
- QTest::qWait(secs * 1000);
-}
-
diff --git a/resourcetester/system.h b/resourcetester/system.h
deleted file mode 100644
index 55240cb..0000000
--- a/resourcetester/system.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- Copyright (c) 2009 Volker Krause <vkrause@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 SYSTEM_H
-#define SYSTEM_H
-
-#include <QObject>
-
-class System : public QObject
-{
- Q_OBJECT
-public:
- explicit System(QObject *parent = Q_NULLPTR);
-
-public slots:
- void exec(const QString &program, const QStringList &args);
- void sleep(int secs);
-};
-
-#endif
diff --git a/resourcetester/test.cpp b/resourcetester/test.cpp
deleted file mode 100644
index be9745a..0000000
--- a/resourcetester/test.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- Copyright (c) 2009 Volker Krause <vkrause@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 "test.h"
-#include "resource.h"
-#include "global.h"
-
-#include <QDebug>
-#include <KMessageBox>
-#include <stdlib.h>
-
-Test *Test::mSelf = 0;
-
-Test::Test(QObject *parent) :
- QObject(parent)
-{
-}
-
-void Test::verify(bool value)
-{
- if (!value) {
- fail("Assertion failed.");
- }
-}
-
-void Test::verify(QObject *object, const QString &slot)
-{
- qDebug() << object << slot;
- bool result = false;
- if (!QMetaObject::invokeMethod(object, slot.toLatin1(), Q_RETURN_ARG(bool, \
result))) {
- fail("Unable to call method " + slot);
- }
-
- if (result) {
- return;
- }
-
- QString lastError = QString("Call to method " + slot + " returned false.");
- QMetaObject::invokeMethod(object, "lastError", Q_RETURN_ARG(QString, \
lastError));
- fail(lastError);
-}
-
-void Test::fail(const QString &error)
-{
- qCritical() << error;
- abort();
-}
-
-void Test::abort()
-{
- Global::cleanup();
- exit(-1);
-}
-
-void Test::alert(const QString &msg)
-{
- KMessageBox::information(0, msg);
-}
-
-Test *Test::instance()
-{
- if (!mSelf) {
- mSelf = new Test(Global::parent());
- }
- return mSelf;
-}
-
diff --git a/resourcetester/test.h b/resourcetester/test.h
deleted file mode 100644
index b887a47..0000000
--- a/resourcetester/test.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Copyright (c) 2009 Volker Krause <vkrause@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 TEST_H
-#define TEST_H
-
-#include <QObject>
-
-class Test : public QObject
-{
- Q_OBJECT
-public:
- static Test *instance();
-
-public slots:
- void verify(bool value);
- void verify(QObject *object, const QString &slot);
- void fail(const QString &error);
- void abort();
- void alert(const QString &msg);
-
-private:
- Test(QObject *parent = Q_NULLPTR);
-
- static Test *mSelf;
-};
-
-#endif
diff --git a/resourcetester/wrappedobject.cpp b/resourcetester/wrappedobject.cpp
deleted file mode 100644
index 36ba7c6..0000000
--- a/resourcetester/wrappedobject.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- Copyright (c) 2009 Volker Krause <vkrause@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 "wrappedobject.h"
-
-int WrappedObject::mInstanceCounter = 0;
diff --git a/resourcetester/wrappedobject.h b/resourcetester/wrappedobject.h
deleted file mode 100644
index c808b7e..0000000
--- a/resourcetester/wrappedobject.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Copyright (c) 2009 Volker Krause <vkrause@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 WRAPPEDOBJECT_H
-#define WRAPPEDOBJECT_H
-
-#include <QObject>
-
-class WrappedObject
-{
-protected:
- template <typename T>
- QObject *createNewInstance(QObject *parent)
- {
- T *instance = new T(parent);
- instance->setObjectName(instance->metaObject()->className() + \
QString::number(++mInstanceCounter));
- return instance;
- }
-
-private:
- static int mInstanceCounter;
-};
-
-#endif
diff --git a/resourcetester/xmloperations.cpp b/resourcetester/xmloperations.cpp
deleted file mode 100644
index aadac0f..0000000
--- a/resourcetester/xmloperations.cpp
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- Copyright (c) 2009 Volker Krause <vkrause@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 "xmloperations.h"
-#include "global.h"
-#include "test.h"
-
-#include <AkonadiCore/collectionfetchjob.h>
-#include <AkonadiCore/collectionfetchscope.h>
-#include <AkonadiCore/itemfetchjob.h>
-#include <AkonadiCore/itemfetchscope.h>
-#include <AkonadiXml/xmlwritejob.h>
-
-#include <QDebug>
-
-#include <QDir>
-#include <QFileInfo>
-#include <QStringList>
-
-using namespace Akonadi;
-
-template <typename T> QTextStream &operator<<(QTextStream &s, const QSet<T> &set)
-{
- s << '{';
- foreach (const T &element, set) {
- s << element << ", ";
- }
- s << '}';
- return s;
-}
-
-QTextStream &operator<<(QTextStream &s, const QStringList &list)
-{
- s << '(' << list.join(", ") << ')';
- return s;
-}
-
-XmlOperations::XmlOperations(QObject *parent) :
- QObject(parent),
- mCollectionFields(0xFF),
- mCollectionKey(RemoteId),
- mItemFields(0xFF),
- mItemKey(ItemRemoteId),
- mNormalizeRemoteIds(false)
-{
-}
-
-XmlOperations::~XmlOperations()
-{
-}
-
-Item XmlOperations::getItemByRemoteId(const QString &rid)
-{
- return mDocument.itemByRemoteId(rid, true);
-}
-
-Collection XmlOperations::getCollectionByRemoteId(const QString &rid)
-{
- return mDocument.collectionByRemoteId(rid);
-}
-
-void XmlOperations::setRootCollections(const QString &resourceId)
-{
- CollectionFetchJob *job = new CollectionFetchJob(Collection::root(), \
CollectionFetchJob::FirstLevel, this);
- job->fetchScope().setAncestorRetrieval(CollectionFetchScope::All);
- job->fetchScope().setResource(resourceId);
- if (job->exec()) {
- setRootCollections(job->collections());
- } else {
- mErrorMsg = job->errorText();
- }
-}
-
-void XmlOperations::setRootCollections(const Collection::List &roots)
-{
- mRoots = roots;
-}
-
-void XmlOperations::setXmlFile(const QString &fileName)
-{
- mFileName = fileName;
- if (QFileInfo(fileName).isAbsolute()) {
- mDocument.loadFile(fileName);
- } else {
- mDocument.loadFile(Global::basePath() + QDir::separator() + fileName);
- }
-}
-
-QString XmlOperations::lastError() const
-{
- return mErrorMsg;
-}
-
-void XmlOperations::setCollectionKey(XmlOperations::CollectionField field)
-{
- mCollectionKey = field;
-}
-
-void XmlOperations::setCollectionKey(const QString &fieldName)
-{
- const QMetaEnum me = \
metaObject()->enumerator(metaObject()->indexOfEnumerator("CollectionField"));
- setCollectionKey(static_cast<CollectionField>(me.keyToValue(fieldName.toLatin1())));
-}
-
-void XmlOperations::ignoreCollectionField(XmlOperations::CollectionField field)
-{
- mCollectionFields = mCollectionFields & ~field;
-}
-
-void XmlOperations::ignoreCollectionField(const QString &fieldName)
-{
- const QMetaEnum me = \
metaObject()->enumerator(metaObject()->indexOfEnumerator("CollectionField"));
- ignoreCollectionField(static_cast<CollectionField>(me.keyToValue(fieldName.toLatin1())));
-}
-
-void XmlOperations::setItemKey(XmlOperations::ItemField field)
-{
- mItemKey = field;
-}
-
-void XmlOperations::setItemKey(const QString &_fieldName)
-{
- QString fieldName = _fieldName;
- if (!fieldName.startsWith(QLatin1String("Item"))) {
- fieldName.prepend("Item");
- }
- const QMetaEnum me = \
metaObject()->enumerator(metaObject()->indexOfEnumerator("ItemField"));
- setItemKey(static_cast<ItemField>(me.keyToValue(fieldName.toLatin1())));
-}
-
-void XmlOperations::ignoreItemField(XmlOperations::ItemField field)
-{
- mItemFields = mItemFields & ~field;
-}
-
-void XmlOperations::ignoreItemField(const QString &_fieldName)
-{
- QString fieldName = _fieldName;
- if (!fieldName.startsWith("Item")) {
- fieldName.prepend("Item");
- }
- const QMetaEnum me = \
metaObject()->enumerator(metaObject()->indexOfEnumerator("ItemField"));
- ignoreItemField(static_cast<ItemField>(me.keyToValue(fieldName.toLatin1())));
-}
-
-void XmlOperations::setNormalizeRemoteIds(bool enable)
-{
- mNormalizeRemoteIds = enable;
-}
-
-bool XmlOperations::compare()
-{
- if (!mDocument.isValid()) {
- mErrorMsg = mDocument.lastError();
- return false;
- }
-
- if (mRoots.isEmpty()) {
- if (!mErrorMsg.isEmpty()) {
- mErrorMsg = QLatin1String("No root collections specified.");
- }
- return false;
- }
-
- const Collection::List docRoots = \
mDocument.childCollections(Collection::root());
- if (compareCollections(mRoots, docRoots)) {
- return true;
- }
-
- XmlWriteJob *xmlJob = new XmlWriteJob(mRoots, mFileName + ".actual", this);
- if (!xmlJob->exec()) {
- qCritical() << xmlJob->errorText();
- }
- return false;
-}
-
-void XmlOperations::assertEqual()
-{
- if (!compare()) {
- Test::instance()->fail(lastError());
- }
-}
-
-static QString normalizeRemoteId(const QString &in)
-{
- QString out(in);
- if (in.startsWith(Global:: basePath())) {
- out = in.mid(Global::basePath().length());
- if (out.startsWith(QDir::separator())) {
- out = out.mid(1);
- }
- }
- return out;
-}
-
-Collection XmlOperations::normalizeCollection(const Collection &in) const
-{
- Collection out(in);
- if (mNormalizeRemoteIds) {
- out.setRemoteId(normalizeRemoteId(in.remoteId()));
- }
- QStringList l = in.contentMimeTypes();
- std::sort(l.begin(), l.end());
- out.setContentMimeTypes(l);
- return out;
-}
-
-Item XmlOperations::normalizeItem(const Item &in) const
-{
- Item out(in);
- if (mNormalizeRemoteIds) {
- out.setRemoteId(normalizeRemoteId(in.remoteId()));
- }
- return out;
-}
-
-bool XmlOperations::compareCollections(const Collection::List &_cols, const \
Collection::List &_refCols)
-{
- Collection::List cols;
- foreach (const Collection &c, _cols) {
- cols.append(normalizeCollection(c));
- }
- Collection::List refCols;
- foreach (const Collection &c, _refCols) {
- refCols.append(normalizeCollection(c));
- }
-
- switch (mCollectionKey) {
- case RemoteId:
- sortEntityList(cols, &Collection::remoteId);
- sortEntityList(refCols, &Collection::remoteId);
- break;
- case Name:
- sortEntityList(cols, &Collection::name);
- sortEntityList(refCols, &Collection::name);
- break;
- case None:
- break;
- default:
- Q_ASSERT(false);
- }
-
- for (int i = 0; i < cols.count(); ++i) {
- const Collection col = cols.at(i);
- if (refCols.count() <= i) {
- mErrorMsg = QString::fromLatin1("Additional collection with remote id \
'%1' was found.").arg(col.remoteId());
- return false;
- }
-
- const Collection refCol = refCols.at(i);
- if (!compareCollection(col, refCol)) {
- return false;
- }
- }
-
- if (refCols.count() != cols.count()) {
- const Collection refCol = refCols.at(cols.count());
- mErrorMsg = QString::fromLatin1("Collection with remote id '%1' is \
missing.").arg(refCol.remoteId());
- return false;
- }
-
- return true;
-}
-
-bool XmlOperations::compareCollection(const Collection &col, const Collection \
&refCol)
-{
- // compare the two collections
- if (!compareValue(col, refCol, &Collection::remoteId, RemoteId) ||
- !compareValue(col, refCol, &Collection::contentMimeTypes, \
ContentMimeType) ||
- !compareValue(col, refCol, &Collection::name, Name)) {
- return false;
- }
-
- if ((mCollectionFields & Attributes) && !compareAttributes(col, refCol)) {
- return false;
- }
-
- // compare child items
- ItemFetchJob *ijob = new ItemFetchJob(col, this);
- ijob->fetchScope().fetchAllAttributes(true);
- ijob->fetchScope().fetchFullPayload(true);
- if (!ijob->exec()) {
- mErrorMsg = ijob->errorText();
- return false;
- }
- const Item::List items = ijob->items();
- const Item::List refItems = mDocument.items(refCol, true);
- if (!compareItems(items, refItems)) {
- return false;
- }
-
- // compare child collections
- CollectionFetchJob *cjob = new CollectionFetchJob(col, \
CollectionFetchJob::FirstLevel, this);
- cjob->fetchScope().setAncestorRetrieval(CollectionFetchScope::All);
- if (!cjob->exec()) {
- mErrorMsg = cjob->errorText();
- return false;
- }
- const Collection::List cols = cjob->collections();
- const Collection::List refCols = mDocument.childCollections(refCol);
- return compareCollections(cols, refCols);
-}
-
-bool XmlOperations::hasItem(const Item &_item, const Collection &_col)
-{
- ItemFetchJob *ijob = new ItemFetchJob(_col, this);
- ijob->fetchScope().fetchAllAttributes(true);
- ijob->fetchScope().fetchFullPayload(true);
- if (!ijob->exec()) {
- mErrorMsg = ijob->errorText();
- return false;
- }
- const Item::List items = ijob->items();
-
- for (int i = 0; i < items.count(); ++i) {
- if (_item == items.at(i)) {
- return true;
- }
- }
- return false;
-}
-
-bool XmlOperations::hasItem(const Item &_item, const QString &rid)
-{
- CollectionFetchJob *job = new CollectionFetchJob(Collection::root(), \
CollectionFetchJob::FirstLevel, this);
- Collection::List colist;
-
- if (job->exec()) {
- colist = job->collections() ;
- }
- foreach (const Collection &collection, colist) {
- if (rid == collection.remoteId()) {
- return hasItem(_item, collection);
- }
- }
- return false;
-}
-
-bool XmlOperations::compareItems(const Item::List &_items, const Item::List \
&_refItems)
-{
- Item::List items;
- foreach (const Item &i, _items) {
- items.append(normalizeItem(i));
- }
- Item::List refItems;
- foreach (const Item &i, _refItems) {
- refItems.append(normalizeItem(i));
- }
-
- switch (mItemKey) {
- case ItemRemoteId:
- sortEntityList(items, &Item::remoteId);
- sortEntityList(refItems, &Item::remoteId);
- break;
- case ItemNone:
- break;
- default:
- Q_ASSERT(false);
- }
-
- for (int i = 0; i < items.count(); ++i) {
- const Item item = items.at(i);
- if (refItems.count() <= i) {
- mErrorMsg = QString::fromLatin1("Additional item with remote id '%1' was \
found.").arg(item.remoteId());
- return false;
- }
-
- const Item refItem = refItems.at(i);
- if (!compareItem(item, refItem)) {
- return false;
- }
- }
-
- if (refItems.count() != items.count()) {
- const Item refItem = refItems.at(items.count());
- mErrorMsg = QString::fromLatin1("Item with remote id '%1' is \
missing.").arg(refItem.remoteId());
- return false;
- }
-
- return true;
-}
-
-bool XmlOperations::compareItem(const Item &item, const Item &refItem)
-{
- if (!compareValue(item, refItem, &Item::remoteId, ItemRemoteId) ||
- !compareValue(item, refItem, &Item::mimeType, ItemMimeType) ||
- !compareValue(item, refItem, &Item::flags, ItemFlags) ||
- !compareValue(item, refItem, &Item::payloadData, ItemPayload)) {
- return false;
- }
-
- return compareAttributes(item, refItem);
-}
-
-bool XmlOperations::compareAttributes(const Entity &entity, const Entity &refEntity)
-{
- Attribute::List attrs = entity.attributes();
- Attribute::List refAttrs = refEntity.attributes();
- std::sort(attrs.begin(), attrs.end(), boost::bind(&Attribute::type, _1) < \
boost::bind(&Attribute::type, _2));
- std::sort(refAttrs.begin(), refAttrs.end(), boost::bind(&Attribute::type, _1) < \
boost::bind(&Attribute::type, _2));
-
- for (int i = 0; i < attrs.count(); ++i) {
- Attribute *attr = attrs.at(i);
- if (refAttrs.count() <= i) {
- mErrorMsg = QString::fromLatin1("Additional attribute of type '%1' for \
object with remote id '%2' was found.")
- \
.arg(QString::fromLatin1(attr->type())).arg(entity.remoteId());
- return false;
- }
-
- Attribute *refAttr = refAttrs.at(i);
- if (attr->type() != refAttr->type()) {
- mErrorMsg = QString::fromLatin1("Object with remote id '%1' misses \
attribute of type '%2'.")
- \
.arg(entity.remoteId()).arg(QString::fromLatin1(refAttr->type()));
- return false;
- }
-
- bool result = compareValue(attr->serialized(), refAttr->serialized());
- if (!result) {
- mErrorMsg.prepend(QString::fromLatin1("Object with remote id '%1' \
differs in attribute '%2':\n")
- \
.arg(entity.remoteId()).arg(QString::fromLatin1(attr->type())));
- return false;
- }
- }
-
- if (refAttrs.count() != attrs.count()) {
- Attribute *refAttr = refAttrs.at(attrs.count());
- mErrorMsg = QString::fromLatin1("Object with remote id '%1' misses attribute \
of type '%2'.")
- \
.arg(entity.remoteId()).arg(QString::fromLatin1(refAttr->type()));;
- return false;
- }
-
- return true;
-}
-
diff --git a/resourcetester/xmloperations.h b/resourcetester/xmloperations.h
deleted file mode 100644
index f5399a2..0000000
--- a/resourcetester/xmloperations.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- Copyright (c) 2009 Volker Krause <vkrause@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 XMLOPERATIONS_H
-#define XMLOPERATIONS_H
-
-#include <AkonadiCore/collection.h>
-#include <AkonadiCore/item.h>
-#include <AkonadiXml//xmldocument.h>
-
-#include <QtCore/QMetaEnum>
-#include <QtCore/QObject>
-#include <QtCore/QTextStream>
-
-#include <boost/bind.hpp>
-#include <algorithm>
-
-/**
- Compares a Akonadi collection sub-tree with reference data supplied in an XML \
file.
-*/
-class XmlOperations : public QObject
-{
- Q_OBJECT
- Q_ENUMS(CollectionField ItemField)
-
-public:
- explicit XmlOperations(QObject *parent = Q_NULLPTR);
- ~XmlOperations();
-
- enum CollectionField {
- None = 0,
- RemoteId = 1,
- Name = 2,
- ContentMimeType = 4,
- Attributes = 8
- };
-
- enum ItemField {
- ItemNone = 0,
- ItemRemoteId = 1,
- ItemMimeType = 2,
- ItemFlags = 4,
- ItemPayload = 8
- };
-
- Q_DECLARE_FLAGS(CollectionFields, CollectionField)
- Q_DECLARE_FLAGS(ItemFields, ItemField)
-
- void setCollectionKey(CollectionField field);
- void ignoreCollectionField(CollectionField field);
- void setItemKey(ItemField field);
- void ignoreItemField(ItemField field);
-
-public slots:
- void setRootCollections(const QString &resourceId);
- void setRootCollections(const Akonadi::Collection::List &roots);
- void setXmlFile(const QString &fileName);
-
- Akonadi::Item getItemByRemoteId(const QString &rid);
- Akonadi::Collection getCollectionByRemoteId(const QString &rid);
-
- void setCollectionKey(const QString &fieldName);
- void ignoreCollectionField(const QString &fieldName);
- void setItemKey(const QString &fieldName);
- void ignoreItemField(const QString &fieldName);
-
- void setNormalizeRemoteIds(bool enable);
-
- bool compare();
- void assertEqual();
-
- QString lastError() const;
-
- bool compareCollections(const Akonadi::Collection::List &cols, const \
Akonadi::Collection::List &refCols);
- bool compareCollection(const Akonadi::Collection &col, const Akonadi::Collection \
&refCol);
- bool compareItems(const Akonadi::Item::List &items, const Akonadi::Item::List \
&refItems);
- bool compareItem(const Akonadi::Item &item, const Akonadi::Item &refItem);
- bool compareAttributes(const Akonadi::Entity &entity, const Akonadi::Entity \
&refEntity);
- bool hasItem(const Akonadi::Item &_item, const Akonadi::Collection &_col);
- bool hasItem(const Akonadi::Item &_item, const QString &rid);
-
-private:
- template <typename T, typename P>
- bool compareValue(const Akonadi::Collection &col, const Akonadi::Collection \
&refCol,
- T(P::*property)() const, CollectionField propertyType);
- template <typename T, typename P>
- bool compareValue(const Akonadi::Item &item, const Akonadi::Item &refItem,
- T(P::*property)() const, ItemField propertyType);
- template <typename T> bool compareValue(const T &value, const T &refValue);
-
- template <typename T, typename E, typename P>
- void sortEntityList(QList<E> &list, T(P::*property)() const) const;
-
- Akonadi::Collection normalizeCollection(const Akonadi::Collection &in) const;
- Akonadi::Item normalizeItem(const Akonadi::Item &in) const;
-
-private:
- Akonadi::Collection::List mRoots;
- Akonadi::XmlDocument mDocument;
- QString mFileName;
- QString mErrorMsg;
- CollectionFields mCollectionFields;
- CollectionField mCollectionKey;
- ItemFields mItemFields;
- ItemField mItemKey;
- bool mNormalizeRemoteIds;
-};
-
-template <typename T, typename P>
-bool XmlOperations::compareValue(const Akonadi::Collection &col, const \
Akonadi::Collection &refCol,
- T(P::*property)() const,
- CollectionField propertyType)
-{
- if (mCollectionFields & propertyType) {
- const bool result = compareValue<T>(((col).*(property))(), \
((refCol).*(property))());
- if (!result) {
- const QMetaEnum me = \
metaObject()->enumerator(metaObject()->indexOfEnumerator("CollectionField"));
- mErrorMsg.prepend(QString::fromLatin1("Collection with remote id '%1' \
differs in property '%2':\n")
- \
.arg(col.remoteId()).arg(me.valueToKey(propertyType)));
- }
- return result;
- }
- return true;
-}
-
-template <typename T, typename P>
-bool XmlOperations::compareValue(const Akonadi::Item &item, const Akonadi::Item \
&refItem,
- T(P::*property)() const,
- ItemField propertyType)
-{
- if (mItemFields & propertyType) {
- const bool result = compareValue<T>(((item).*(property))(), \
((refItem).*(property))());
- if (!result) {
- const QMetaEnum me = \
metaObject()->enumerator(metaObject()->indexOfEnumerator("ItemField"));
- mErrorMsg.prepend(QString::fromLatin1("Item with remote id '%1' differs \
in property '%2':\n")
- \
.arg(item.remoteId()).arg(me.valueToKey(propertyType)));
- }
- return result;
- }
- return true;
-}
-
-template <typename T>
-bool XmlOperations::compareValue(const T &value, const T &refValue)
-{
- if (value == refValue) {
- return true;
- }
- QTextStream ts(&mErrorMsg);
- ts << " Actual: " << value << endl << " Expected: " << refValue;
- return false;
-}
-
-template <typename T, typename E, typename P>
-void XmlOperations::sortEntityList(QList<E> &list, T(P::*property)() const) const
-{
- std::sort(list.begin(), list.end(), boost::bind(property, _1) < \
boost::bind(property, _2));
-}
-
-#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic