Commit 7a8246ef authored by Krzysztof Nowicki's avatar Krzysztof Nowicki Committed by Laurent Montel
Browse files

Expose the main resource DBus interface for testability


Signed-off-by: Krzysztof Nowicki's avatarKrzysztof Nowicki <krissn@op.pl>
parent 88fb9bf3
......@@ -13,9 +13,12 @@ kcfg_generate_dbus_interface(${CMAKE_CURRENT_SOURCE_DIR}/../ewsresource.kcfg org
set(ewssettingsinterface_xml ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Akonadi.Ews.Settings.xml)
qt_generate_dbus_interface( ${CMAKE_CURRENT_SOURCE_DIR}/../ewssettings.h org.kde.Akonadi.Ews.Wallet.xml OPTIONS -a )
set(ewswalletinterface_xml ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Akonadi.Ews.Wallet.xml)
qt_generate_dbus_interface( ${CMAKE_CURRENT_SOURCE_DIR}/../ewsresource.h org.kde.Akonadi.Ews.Resource.xml OPTIONS -a )
set(ewsresourceinterface_xml ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Akonadi.Ews.Resource.xml)
qt_add_dbus_interface(isolatestestcommon_SRCS ${ewssettingsinterface_xml} ewssettings)
qt_add_dbus_interface(isolatestestcommon_SRCS ${ewswalletinterface_xml} ewswallet)
qt_add_dbus_interface(isolatestestcommon_SRCS ${ewsresourceinterface_xml} ewsresource)
add_library(isolatedtestcommon STATIC ${isolatestestcommon_SRCS})
target_link_libraries(isolatedtestcommon
......
......@@ -12,6 +12,7 @@
#include <AkonadiCore/AgentManager>
#include <AkonadiCore/Control>
#include "ewsresourceinterface.h"
#include "ewssettings.h"
#include "ewswallet.h"
#include "fakeewsserverthread.h"
......@@ -103,6 +104,13 @@ TestAgentInstance::TestAgentInstance(const QString &url)
this));
QVERIFY(mEwsWalletInterface->isValid());
mEwsResourceInterface.reset(
new OrgKdeAkonadiEwsResourceInterface(QStringLiteral("org.freedesktop.Akonadi.Resource.") + mIdentifier + QLatin1Char('.') + akonadiInstanceIdentifier,
QStringLiteral("/"),
QDBusConnection::sessionBus(),
this));
QVERIFY(mEwsResourceInterface->isValid());
/* The EWS resource initializes its DBus adapters asynchronously. Therefore it can happen that
* due to a race access is attempted prior to their initialization. To fix this retry the DBus
* communication a few times before declaring failure. */
......@@ -188,6 +196,11 @@ OrgKdeAkonadiEwsWalletInterface &TestAgentInstance::walletInterface() const
return *mEwsWalletInterface;
}
OrgKdeAkonadiEwsResourceInterface &TestAgentInstance::resourceInterface() const
{
return *mEwsResourceInterface;
}
Akonadi::AgentInstance &TestAgentInstance::instance() const
{
return *mEwsInstance;
......
......@@ -20,6 +20,7 @@ class AgentInstance;
class FakeEwsServerThread;
class OrgKdeAkonadiEwsSettingsInterface;
class OrgKdeAkonadiEwsWalletInterface;
class OrgKdeAkonadiEwsResourceInterface;
class IsolatedTestBase : public QObject
{
......@@ -77,12 +78,14 @@ public:
OrgKdeAkonadiEwsSettingsInterface &settingsInterface() const;
OrgKdeAkonadiEwsWalletInterface &walletInterface() const;
OrgKdeAkonadiEwsResourceInterface &resourceInterface() const;
Akonadi::AgentInstance &instance() const;
private:
QScopedPointer<Akonadi::AgentInstance> mEwsInstance;
QScopedPointer<OrgKdeAkonadiEwsSettingsInterface> mEwsSettingsInterface;
QScopedPointer<OrgKdeAkonadiEwsWalletInterface> mEwsWalletInterface;
QScopedPointer<OrgKdeAkonadiEwsResourceInterface> mEwsResourceInterface;
QString mIdentifier;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment