Commit 5ea2533c authored by pvuorela's avatar pvuorela

Merge branch 'combine_common_code_and_packages' into 'master'

Combine common code and packages

See merge request !85
parents efd8bddf 36a9c71a
TEMPLATE = subdirs
SUBDIRS = src
OTHER_FILES += rpm/buteo-sync-plugins-social.spec
TEMPLATE = subdirs
SUBDIRS = src
CONFIG(build-tests) {
SUBDIRS += tests
tests.depends = src
}
OTHER_FILES += rpm/sociald.spec
......@@ -17,26 +17,11 @@ QT -= \
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
# the unit tests need to provide a custom QNAM and uses a different database directory
HEADERS += $$PWD/common/socialdnetworkaccessmanager_p.h
!contains(DEFINES, 'SOCIALD_TEST_DEFINE') {
SOURCES += $$PWD/common/socialdnetworkaccessmanager_p.cpp
}
DEFINES += 'SYNC_DATABASE_DIR=\'\"Sync\"\''
DEFINES += 'SOCIALD_SYNC_DATABASE_NAME=\'\"sociald.db\"\''
INCLUDEPATH += . $$PWD/common/
HEADERS += \
$$PWD/common/buteosyncfw_p.h \
$$PWD/common/socialdbuteoplugin.h \
$$PWD/common/socialnetworksyncadaptor.h \
$$PWD/common/trace.h
SOURCES += \
$$PWD/common/socialdbuteoplugin.cpp \
$$PWD/common/socialnetworksyncadaptor.cpp
LIBS += -L$$PWD/common -lsyncpluginscommon
contains(DEFINES, 'SOCIALD_USE_QTPIM') {
DEFINES *= USE_CONTACTS_NAMESPACE=QTCONTACTS_USE_NAMESPACE
......@@ -49,34 +34,27 @@ contains(DEFINES, 'SOCIALD_USE_QTPIM') {
HEADERS += contactmanagerengine.h
}
# don't pull in buteo plugin framework for unit test builds
!contains (DEFINES, 'SOCIALD_TEST_DEFINE') {
!contains (DEFINES, OUT_OF_PROCESS_PLUGIN) {
TEMPLATE = lib
CONFIG += plugin
target.path = $$[QT_INSTALL_LIBS]/buteo-plugins-qt5
message("building" $$TARGET "as in-process plugin")
}
contains (DEFINES, OUT_OF_PROCESS_PLUGIN) {
TEMPLATE = app
target.path = $$[QT_INSTALL_LIBS]/buteo-plugins-qt5/oopp
message("building" $$TARGET "as out-of-process plugin")
DEFINES += CLIENT_PLUGIN
BUTEO_OOPP_INCLUDE_DIR = $$system(pkg-config --cflags buteosyncfw5|cut -f2 -d'I')
INCLUDEPATH += $$BUTEO_OOPP_INCLUDE_DIR
HEADERS += $$BUTEO_OOPP_INCLUDE_DIR/ButeoPluginIfaceAdaptor.h \
$$BUTEO_OOPP_INCLUDE_DIR/PluginCbImpl.h \
$$BUTEO_OOPP_INCLUDE_DIR/PluginServiceObj.h
SOURCES += $$BUTEO_OOPP_INCLUDE_DIR/ButeoPluginIfaceAdaptor.cpp \
$$BUTEO_OOPP_INCLUDE_DIR/PluginCbImpl.cpp \
$$BUTEO_OOPP_INCLUDE_DIR/PluginServiceObj.cpp \
$$BUTEO_OOPP_INCLUDE_DIR/plugin_main.cpp
}
!contains (DEFINES, OUT_OF_PROCESS_PLUGIN) {
TEMPLATE = lib
CONFIG += plugin
target.path = $$[QT_INSTALL_LIBS]/buteo-plugins-qt5
message("building" $$TARGET "as in-process plugin")
}
contains (DEFINES, OUT_OF_PROCESS_PLUGIN) {
TEMPLATE = app
target.path = $$[QT_INSTALL_LIBS]/buteo-plugins-qt5/oopp
message("building" $$TARGET "as out-of-process plugin")
DEFINES += CLIENT_PLUGIN
BUTEO_OOPP_INCLUDE_DIR = $$system(pkg-config --cflags buteosyncfw5|cut -f2 -d'I')
INCLUDEPATH += $$BUTEO_OOPP_INCLUDE_DIR
HEADERS += $$BUTEO_OOPP_INCLUDE_DIR/ButeoPluginIfaceAdaptor.h \
$$BUTEO_OOPP_INCLUDE_DIR/PluginCbImpl.h \
$$BUTEO_OOPP_INCLUDE_DIR/PluginServiceObj.h
SOURCES += $$BUTEO_OOPP_INCLUDE_DIR/ButeoPluginIfaceAdaptor.cpp \
$$BUTEO_OOPP_INCLUDE_DIR/PluginCbImpl.cpp \
$$BUTEO_OOPP_INCLUDE_DIR/PluginServiceObj.cpp \
$$BUTEO_OOPP_INCLUDE_DIR/plugin_main.cpp
}
#NOTE: This causes issues with the unit tests ?
#MOC_DIR = $$PWD/../.moc
#OBJECTS_DIR = $$PWD/../.obj
TEMPLATE = lib
QT -= gui
QT += network dbus
CONFIG += link_pkgconfig
PKGCONFIG += \
accounts-qt5 \
buteosyncfw5 \
TARGET = syncpluginscommon
TARGET = $$qtLibraryTarget($$TARGET)
HEADERS += \
$$PWD/buteosyncfw_p.h \
$$PWD/socialdbuteoplugin.h \
$$PWD/socialnetworksyncadaptor.h \
$$PWD/trace.h
SOURCES += \
$$PWD/socialdbuteoplugin.cpp \
$$PWD/socialnetworksyncadaptor.cpp
HEADERS += $$PWD/socialdnetworkaccessmanager_p.h
SOURCES += socialdnetworkaccessmanager_p.cpp
TARGETPATH = $$[QT_INSTALL_LIBS]
target.path = $$TARGETPATH
INSTALLS += target
TEMPLATE = subdirs
SUBDIRS = \
common \
sociald
CONFIG(google): SUBDIRS += google
CONFIG(facebook): SUBDIRS += facebook
CONFIG(twitter): SUBDIRS += twitter
CONFIG(onedrive): SUBDIRS += onedrive
CONFIG(dropbox): SUBDIRS += dropbox
CONFIG(vk): SUBDIRS += vk
CONFIG(knowncontacts): SUBDIRS += knowncontacts
sociald.depends = common
CONFIG(google): {
SUBDIRS += google
google.depends = common
}
CONFIG(facebook): {
SUBDIRS += facebook
facebook.depends = common
}
CONFIG(twitter): {
SUBDIRS += twitter
twitter.depends = common
}
CONFIG(onedrive): {
SUBDIRS += onedrive
onedrive.depends = common
}
CONFIG(dropbox): {
SUBDIRS += dropbox
dropbox.depends = common
}
CONFIG(vk): {
SUBDIRS += vk
vk.depends = common
}
CONFIG(knowncontacts): {
SUBDIRS += knowncontacts
knowncontacts.depends = common
}
/****************************************************************************
**
** Copyright (C) 2013-2014 Jolla Ltd.
** Contact: Chris Adams <chris.adams@jollamobile.com>
**
** This program/library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public License
** version 2.1 as published by the Free Software Foundation.
**
** This program/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 program/library; if not, write to the Free
** Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
** 02110-1301 USA
**
****************************************************************************/
#include "networkstubs_p.h"
#include "socialdnetworkaccessmanager_p.h"
#include <QDateTime>
#include <QTimer>
/*
* This implementation overrides the networking classes for testing purposes.
* The unit test for each social network should provide an implementation of
* TestNetworkReply::generateData() in order to return the required data.
*/
SocialdNetworkAccessManager::SocialdNetworkAccessManager(QObject *parent)
: QNetworkAccessManager(parent)
{
}
QNetworkReply *SocialdNetworkAccessManager::createRequest(QNetworkAccessManager::Operation op,
const QNetworkRequest &req,
QIODevice *outgoingData)
{
Q_UNUSED(op)
Q_UNUSED(outgoingData)
QString generator; // TODO: create generator from request, if we want to test different branches.
// construct a test reply, which will contain the expected data and trigger finished()
TestNetworkReply *retn = new TestNetworkReply(this);
retn->setOperation(op);
retn->setRequest(req);
retn->setUrl(req.url());
retn->m_readAllData = TestNetworkReply::generateData(req.url(), generator);
retn->open(QIODevice::ReadOnly);
retn->setFinished(true);
QTimer::singleShot(100, retn, SIGNAL(finished()));
return retn;
}
/****************************************************************************
**
** Copyright (C) 2013-2014 Jolla Ltd.
** Contact: Chris Adams <chris.adams@jollamobile.com>
**
** This program/library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public License
** version 2.1 as published by the Free Software Foundation.
**
** This program/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 program/library; if not, write to the Free
** Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
** 02110-1301 USA
**
****************************************************************************/
#ifndef SOCIALD_TESTS_NETWORKSTUBS_P_H
#define SOCIALD_TESTS_NETWORKSTUBS_P_H
#include <QByteArray>
#include <QNetworkReply>
#include <QUrl>
#include <QString>
#include <QtDebug>
#include "socialdnetworkaccessmanager_p.h"
class TestNetworkReply : public QNetworkReply
{
Q_OBJECT
public:
bool isSequential() const { return true; }
void abort() { qWarning() << "TNR::abort"; }
qint64 bytesAvailable() const { return m_readAllData.size() + QIODevice::bytesAvailable(); }
qint64 size() const { return bytesAvailable(); }
bool atEnd() const { return m_readAllData.size() == 0; }
bool canReadLine() const { return !atEnd(); }
qint64 readData(char *buf, qint64 sz) {
qint64 i = 0;
while (!m_readAllData.isEmpty() && i++ < sz) {
*buf++ = m_readAllData.at(0);
m_readAllData.remove(0,1);
}
return i;
}
protected:
TestNetworkReply(QObject *parent = 0) : QNetworkReply(parent) {}
private:
static QByteArray generateData(const QUrl &requestUrl, const QString &generator);
QByteArray m_readAllData;
friend class SocialdNetworkAccessManager;
};
#endif
TEMPLATE = subdirs
SUBDIRS =
CONFIG(google): SUBDIRS += tst_google
CONFIG(twitter): SUBDIRS += tst_twitter
QMAKE_EXTRA_TARGETS += check
DEFINES += SOCIALD_TEST_DEFINE
DEFINES += 'PRIVILEGED_DATA_DIR=\'\"/tmp\"\''
DEFINES += SOCIALD_USE_QTPIM
include($$PWD/../src/common.pri)
INCLUDEPATH += $$PWD
HEADERS += $$PWD/networkstubs_p.h
SOURCES += $$PWD/networkstubs_p.cpp
QT += testlib
TEMPLATE = app
CONFIG -= app_bundle
target.path = /opt/tests/sociald
INSTALLS += target
/****************************************************************************
**
** Copyright (C) 2013-2014 Jolla Ltd.
** Contact: Chris Adams <chris.adams@jollamobile.com>
**
** This program/library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public License
** version 2.1 as published by the Free Software Foundation.
**
** This program/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 program/library; if not, write to the Free
** Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
** 02110-1301 USA
**
****************************************************************************/
#define QT_STATICPLUGIN
#include <QtGlobal>
#include <QTest>
#include "constants_p.h"
#include <qtcontacts-extensions_impl.h>
#include <qcontactoriginmetadata_impl.h>
#include "googlecalendarsyncadaptor.h"
#include "googletwowaycontactsyncadaptor.h"
class tst_google : public QObject
{
Q_OBJECT
public:
tst_google();
virtual ~tst_google();
public slots:
void initTestCase();
void cleanupTestCase();
void init();
void cleanup();
private slots:
void calendars();
void contacts();
};
// --------------------------------
tst_google::tst_google()
{
}
tst_google::~tst_google()
{
}
void tst_google::initTestCase()
{
}
void tst_google::cleanupTestCase()
{
}
void tst_google::init()
{
}
void tst_google::cleanup()
{
}
// --------------------------------
void tst_google::calendars()
{
QScopedPointer<GoogleCalendarSyncAdaptor> ggCalSa(new GoogleCalendarSyncAdaptor(this));
QSKIP("TODO: write unit tests for this");
}
void tst_google::contacts()
{
QScopedPointer<GoogleTwoWayContactSyncAdaptor> ggConSa(new GoogleTwoWayContactSyncAdaptor(this));
QSKIP("TODO: write unit tests for this");
}
// --------------------------------
QTEST_MAIN(tst_google)
#include "tst_google.moc"
TARGET = tst_google
include(../tst_common.pri)
include($$PWD/../../src/google/google-common.pri)
include($$PWD/../../src/google/google-calendars/google-calendars.pri)
include($$PWD/../../src/google/google-contacts/google-contacts.pri)
SOURCES += \
tst_google.cpp \
tst_googlenetworkstubs_p.cpp
/****************************************************************************
**
** Copyright (C) 2013-2014 Jolla Ltd.
** Contact: Chris Adams <chris.adams@jollamobile.com>
**
** This program/library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public License
** version 2.1 as published by the Free Software Foundation.
**
** This program/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 program/library; if not, write to the Free
** Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
** 02110-1301 USA
**
****************************************************************************/
#include "networkstubs_p.h"
#include "socialdnetworkaccessmanager_p.h"
#include <QDateTime>
#include <QTimer>
static QByteArray createGoogleCalendarsData(const QString &generator)
{
Q_UNUSED(generator);
// XXX TODO
return QByteArray();
}
static QByteArray createGoogleContactsData(const QString &generator)
{
Q_UNUSED(generator);
// XXX TODO
return QByteArray();
}
QByteArray TestNetworkReply::generateData(const QUrl &requestUrl, const QString &generator)
{
// we inspect the request url and based upon what we see there, generate some data.
QString host = requestUrl.host();
QString path = requestUrl.path();
if (host == QLatin1String("google.com")) {
if (path == QLatin1String("/calendars")) {
return createGoogleCalendarsData(generator);
} else if (path == QLatin1String("/contacts")) {
return createGoogleContactsData(generator);
}
}
// no test data function exists for this host/path combination
qWarning() << Q_FUNC_INFO << "no test data function exists for:" << host << path;
return QByteArray();
}
/****************************************************************************
**
** Copyright (C) 2013-2014 Jolla Ltd.
** Contact: Chris Adams <chris.adams@jollamobile.com>
**
** This program/library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public License
** version 2.1 as published by the Free Software Foundation.
**
** This program/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 program/library; if not, write to the Free
** Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
** 02110-1301 USA
**
****************************************************************************/
#define QT_STATICPLUGIN
#include <QtGlobal>
#include <QTest>
#include "twitterhometimelinesyncadaptor.h"
#include "twitternotificationsyncadaptor.h"
class tst_twitter : public QObject
{
Q_OBJECT
public:
tst_twitter();
virtual ~tst_twitter();
public slots:
void initTestCase();
void cleanupTestCase();
void init();
void cleanup();
private slots:
void notifications();
void posts();
};
// --------------------------------
tst_twitter::tst_twitter()
{
}
tst_twitter::~tst_twitter()
{
}
void tst_twitter::initTestCase()
{
}
void tst_twitter::cleanupTestCase()
{
}
void tst_twitter::init()
{
}
void tst_twitter::cleanup()
{
}
// --------------------------------
void tst_twitter::notifications()
{
QScopedPointer<TwitterNotificationSyncAdaptor> fbNotSa(new TwitterNotificationSyncAdaptor(this));
QSKIP("TODO: write unit tests for this");
}
void tst_twitter::posts()
{
QScopedPointer<TwitterHomeTimelineSyncAdaptor> fbNotSa(new TwitterHomeTimelineSyncAdaptor(this));
QSKIP("TODO: write unit tests for this");
}
// --------------------------------
QTEST_MAIN(tst_twitter)
#include "tst_twitter.moc"
TARGET = tst_twitter
include(../tst_common.pri)
include($$PWD/../../src/twitter/twitter-common.pri)
include($$PWD/../../src/twitter/twitter-notifications/twitter-notifications.pri)
include($$PWD/../../src/twitter/twitter-posts/twitter-posts.pri)
SOURCES += \
tst_twitter.cpp \
tst_twitternetworkstubs_p.cpp
/****************************************************************************
**
** Copyright (C) 2013-2014 Jolla Ltd.
** Contact: Chris Adams <chris.adams@jollamobile.com>
**
** This program/library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public License
** version 2.1 as published by the Free Software Foundation.
**
** This program/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 program/library; if not, write to the Free
** Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
** 02110-1301 USA
**
****************************************************************************/
#include "networkstubs_p.h"
#include "socialdnetworkaccessmanager_p.h"
#include <QDateTime>
#include <QTimer>
static QByteArray createTwitterHomeTimelineData(const QString &generator)
{
Q_UNUSED(generator);
// XXX TODO
return QByteArray();
}
static QByteArray createTwitterMentionsTimelineData(const QString &generator)
{
Q_UNUSED(generator);
// XXX TODO
return QByteArray();
}
QByteArray TestNetworkReply::generateData(const QUrl &requestUrl, const QString &generator)
{
// we inspect the request url and based upon what we see there, generate some data.
QString host = requestUrl.host();
QString path = requestUrl.path();
if (host == QLatin1String("twitter.com")) {
if (path == QLatin1String("/home")) {
return createTwitterHomeTimelineData(generator);
} else if (path == QLatin1String("/mentions")) {
return createTwitterMentionsTimelineData(generator);
}
}
// no test data function exists for this host/path combination
qWarning() << Q_FUNC_INFO << "no test data function exists for:" << host << path;
return QByteArray();
}
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