QNetworkReply *NetworkAccessManager::get(const QNetworkRequest &request, bool onlineRequestsOnly)
{
- qDebug() << __PRETTY_FUNCTION__;
+ qWarning() << __PRETTY_FUNCTION__;
//Disconnected from network, queue request and return empty reply.
if (!m_networkHandler->isConnected()) {
#include <QList>
#include <QHash>
-#include <QNetworkReply>
-#include <QNetworkRequest>
-#include <QAbstractNetworkCache>
+#include <QtNetwork/QNetworkReply>
+#include <QtNetwork/QNetworkRequest>
+#include <QtNetwork/QAbstractNetworkCache>
class NetworkHandler;
class QNetworkAccessManager;
#ifndef NETWORKREPLY_H
#define NETWORKREPLY_H
-#include <QNetworkReply>
-#include <QNetworkRequest>
+#include <QtNetwork/QNetworkReply>
+#include <QtNetwork/QNetworkRequest>
/**
* @brief NetworkReply class.
#include <QObject>
-#include <QSqlDatabase>
-#include <QSqlError>
+#include <QtSql/QSqlDatabase>
+#include <QtSql/QSqlError>
#include <QFile>
#include <QStringList>
#include <QtAlgorithms>
#include <QDebug>
-#include <QNetworkReply>
+#include <QtNetwork/QNetworkReply>
#include <QPixmap>
#include <QStringList>
#include <QtGlobal>
#include "situareservice.h"
-SituareService::SituareService(QObject *parent)
+SituareService::SituareService(NetworkAccessManager *networkManager, ImageFetcher *imageFetcher,
+ QObject *parent)
: QObject(parent),
m_user(0)
{
qDebug() << __PRETTY_FUNCTION__;
- m_networkManager = new NetworkAccessManager(this);
+ m_networkManager = networkManager;
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(requestFinished(QNetworkReply*)), Qt::QueuedConnection);
- m_imageFetcher = new ImageFetcher(new NetworkAccessManager(this), this);
+ m_imageFetcher = imageFetcher;
connect(this, SIGNAL(fetchImage(QString, QUrl)),
m_imageFetcher, SLOT(fetchImage(QString, QUrl)));
connect(m_imageFetcher, SIGNAL(imageReceived(QString,QPixmap)),
public:
/**
+ * Unit test class
+ */
+ friend class TestSituareService;
+
+ /**
* @brief Default constructor
*
* @param parent instance of parent
*/
- SituareService(QObject *parent = 0);
+ SituareService(NetworkAccessManager *networkManager, ImageFetcher *imageFetcher,
+ QObject *parent = 0);
/**
* @brief Destructor
/*******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
-
/**
* @brief Retrieves people with similart interest (same tags).
*
--- /dev/null
+#-------------------------------------------------
+#
+# Project created by QtCreator 2010-07-09T12:32:33
+#
+#-------------------------------------------------
+
+QT += testlib network sql
+
+CONFIG += console
+CONFIG -= app_bundle
+
+TEMPLATE = app
+
+INCLUDEPATH += /usr/include/qjson
+LIBS += -lqjson
+
+
+SOURCES += testsituareservice.cpp \
+ ../../src/situareservice/situareservice.cpp \
+ ../../src/user/user.cpp \
+ ../../tests/stubs/stubbase.cpp \
+ ../../src/facebookservice/facebookauthentication.cpp \
+ ../../src/facebookservice/facebookcredentials.cpp \
+ ../../src/situareservice/database.cpp \
+ ../../src/coordinates/geocoordinate.cpp \
+ ../../src/coordinates/scenecoordinate.cpp \
+ ../../src/ui/avatarimage.cpp \
+ ../../src/situareservice/notification.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+
+INCLUDEPATH += . \
+ ../../src/ \
+ ../../tests/stubs
+
+HEADERS += \
+ ../../src/situareservice/situareservice.h \
+ ../../src/user/user.h \
+ ../../tests/stubs/networkaccessmanagerstub.h \
+ ../../tests/stubs/imagefetcherstub.h \
+ ../../src/network/networkaccessmanager.h \
+ ../../src/situareservice/imagefetcher.h \
+ ../../tests/stubs/stubbase.h \
+ ../../src/facebookservice/facebookauthentication.h \
+ ../../src/facebookservice/facebookcredentials.h \
+ ../../src/situareservice/database.h \
+ ../../src/coordinates/geocoordinate.h \
+ ../../src/coordinates/scenecoordinate.h \
+ ../../src/ui/avatarimage.h \
+ ../../src/situareservice/notification.h
+
+DEFINES += QT_NO_DEBUG_OUTPUT
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Jussi Laitinen - jussi.laitinen@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+
+#include <QtCore/QString>
+#include <QtTest/QtTest>
+
+#include "situareservice/situareservice.h"
+#include "networkaccessmanagerstub.h"
+#include "imagefetcherstub.h"
+
+class TestSituareService : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void init();
+ void cleanup();
+ void testSendRequest();
+
+private:
+ SituareService *m_situareService;
+ NetworkAccessManager *m_networkAccessManager;
+ ImageFetcher *m_imageFetcher;
+};
+
+void TestSituareService::init()
+{
+ m_networkAccessManager = new NetworkAccessManager();
+ m_imageFetcher = new ImageFetcher(m_networkAccessManager);
+ m_situareService = new SituareService(m_networkAccessManager, m_imageFetcher);
+
+ QVERIFY(m_networkAccessManager);
+ QVERIFY(m_imageFetcher);
+ QVERIFY(m_situareService);
+
+ networkAccessManagerStub->stubReset();
+ imageFetcherStub->stubReset();
+}
+
+void TestSituareService::cleanup()
+{
+ delete m_situareService;
+}
+
+void TestSituareService::testSendRequest()
+{
+ QUrl url("http://example.com");
+ QNetworkRequest request;
+ request.setUrl(url);
+
+ m_situareService->sendRequest(url, QString(), QString());
+
+ QCOMPARE(networkAccessManagerStub->stubCallCount("get"), 1);
+ QNetworkRequest getRequest = networkAccessManagerStub->stubLastCall().parameter<const QNetworkRequest &>(0);
+}
+
+QTEST_APPLESS_MAIN(TestSituareService);
+
+#include "testsituareservice.moc"
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Jussi Laitinen - jussi.laitinen@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+#ifndef IMAGEFETCHERSTUB_H
+#define IMAGEFETCHERSTUB_H
+
+#include "../../src/situareservice/imagefetcher.h"
+#include "stubbase.h"
+
+class ImageFetcherStub : public StubBase
+{
+public:
+ virtual void ImageFetcherConstructor(NetworkAccessManager *manager, QObject *parent = 0);
+ virtual void fetchImage(const QString &id, const QUrl &url);
+ virtual void downloadFinished(QNetworkReply *reply);
+ virtual void startNextDownload();
+};
+
+void ImageFetcherStub::ImageFetcherConstructor(NetworkAccessManager *manager, QObject *parent)
+{
+ Q_UNUSED(manager)
+ Q_UNUSED(parent)
+}
+
+void ImageFetcherStub::fetchImage(const QString &id, const QUrl &url)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QString &>(id));
+ params.append(new Parameter<const QUrl &>(url));
+ stubMethodEntered("fetchImage");
+}
+
+void ImageFetcherStub::downloadFinished(QNetworkReply *reply)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QNetworkReply *>(reply));
+ stubMethodEntered("downloadFinished", params);
+}
+
+void ImageFetcherStub::startNextDownload()
+{
+ stubMethodEntered("startNextDownload");
+}
+
+//Create a stub instance
+ImageFetcherStub defaultImageFetcherStub;
+ImageFetcherStub *imageFetcherStub = &defaultImageFetcherStub;
+
+ImageFetcher::ImageFetcher(NetworkAccessManager *manager, QObject *parent)
+{
+ imageFetcherStub->ImageFetcherConstructor(manager, parent);
+}
+
+void ImageFetcher::fetchImage(const QString &id, const QUrl &url)
+{
+ imageFetcherStub->fetchImage(id, url);
+}
+
+void ImageFetcher::downloadFinished(QNetworkReply *reply)
+{
+ imageFetcherStub->downloadFinished(reply);
+}
+
+void ImageFetcher::startNextDownload()
+{
+ imageFetcherStub->startNextDownload();
+}
+
+#endif // IMAGEFETCHERSTUB_H
+
--- /dev/null
+/***************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (directui@nokia.com)
+**
+** This file is part of mhome.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at directui@nokia.com.
+**
+** This 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
+** and appearing in the file LICENSE.LGPL included in the packaging
+** of this file.
+**
+****************************************************************************/
+#ifndef STUBMETHOD_H
+#define STUBMETHOD_H
+
+#include <QString>
+
+class MethodCall
+{
+public:
+ MethodCall(const QString &name, QList<ParameterBase *> params, ParameterBase *returnValue)
+ : _name(name),
+ _params(params),
+ _returnValue(returnValue) {
+ }
+
+ virtual ~MethodCall() {
+ foreach(ParameterBase * p, _params) {
+ delete p;
+ }
+ }
+
+ QString name() {
+ return _name;
+ }
+
+ QList<ParameterBase *> params() {
+ return _params;
+ }
+
+ template <typename T>
+ T parameter(int number) {
+ if (number >= _params.count()) {
+ QString msg = QString("MethodCall::") + __func__ + ": method " + _name + " does not have parameter #" + QString::number(number) + ". Check your test code.";
+ qFatal(qPrintable(msg));
+ }
+ Parameter<T>* param = dynamic_cast<Parameter<T>* >(_params[number]);
+ if (!param) {
+ QString msg = QString("MethodCall::") + __func__ + ": failed dynamic_cast, check that parameter type matches parameter number";
+ qFatal(qPrintable(msg));
+ }
+ return param->data;
+ }
+
+ template <typename T>
+ T returnValue() {
+ Parameter<T>* value = dynamic_cast<Parameter<T>*>(_returnValue);
+
+ if (!value) {
+ QString msg = QString("MethodCall::") + __func__ + ": failed dynamic_cast, check that type matches return value";
+ qFatal(qPrintable(msg));
+ }
+ return value->data;
+ }
+
+ bool returnValueExists() {
+ return (_returnValue != NULL);
+ }
+
+private:
+ QString _name;
+ QList<ParameterBase *> _params;
+ ParameterBase *_returnValue;
+
+};
+
+#endif
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Jussi Laitinen - jussi.laitinen@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#ifndef NETWORKACCESSMANAGERSTUB_H
+#define NETWORKACCESSMANAGERSTUB_H
+
+#include <QtNetwork/QNetworkReply>
+#include <QtNetwork/QNetworkRequest>
+#include <QtNetwork/QAbstractNetworkCache>
+
+#include "../../src/network/networkaccessmanager.h"
+
+#include "stubbase.h"
+
+class NetworkAccessManagerStub : public StubBase
+{
+public:
+ virtual void NetworkAccessManagerConstructor(QObject *parent = 0);
+ virtual bool isConnected();
+ virtual QNetworkReply *get(const QNetworkRequest &request, bool onlineRequestsOnly = false);
+ virtual QNetworkReply *post(const QNetworkRequest &request, QByteArray &data,
+ bool onlineRequestsOnly = false);
+ virtual void setCache(QAbstractNetworkCache *cache);
+ virtual QAbstractNetworkCache *cache() const;
+ virtual void connected();
+ virtual void disconnected();
+ virtual void downloadFinished(QNetworkReply *reply);
+};
+
+void NetworkAccessManagerStub::NetworkAccessManagerConstructor(QObject *parent)
+{
+ Q_UNUSED(parent)
+}
+
+bool NetworkAccessManagerStub::isConnected()
+{
+ return stubReturnValue<bool>("isConnected");
+}
+
+QNetworkReply *NetworkAccessManagerStub::get(const QNetworkRequest &request,
+ bool onlineRequestsOnly)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QNetworkRequest &>(request));
+ params.append(new Parameter<bool>(onlineRequestsOnly));
+ stubMethodEntered("get", params);
+
+ return stubReturnValue<QNetworkReply *>("get");
+}
+
+QNetworkReply *NetworkAccessManagerStub::post(const QNetworkRequest &request, QByteArray &data,
+ bool onlineRequestsOnly)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<const QNetworkRequest &>(request));
+ params.append(new Parameter<QByteArray &>(data));
+ params.append(new Parameter<bool>(onlineRequestsOnly));
+ stubMethodEntered("post", params);
+
+ return stubReturnValue<QNetworkReply *>("post");
+}
+
+void NetworkAccessManagerStub::setCache(QAbstractNetworkCache *cache)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<QAbstractNetworkCache *>(cache));
+ stubMethodEntered("setCache", params);
+}
+
+QAbstractNetworkCache *NetworkAccessManagerStub::cache() const
+{
+ return stubReturnValue<QAbstractNetworkCache *>("cache");
+}
+
+void NetworkAccessManagerStub::connected()
+{
+ stubMethodEntered("connected");
+}
+
+void NetworkAccessManagerStub::disconnected()
+{
+ stubMethodEntered("disconnected");
+}
+
+void NetworkAccessManagerStub::downloadFinished(QNetworkReply *reply)
+{
+ QList<ParameterBase *> params;
+ params.append(new Parameter<QNetworkReply *>(reply));
+ stubMethodEntered("downloadFinished", params);
+}
+
+//Create a stub instance
+NetworkAccessManagerStub defaultNetworkAccessManagerStub;
+NetworkAccessManagerStub *networkAccessManagerStub = &defaultNetworkAccessManagerStub;
+
+//Create a proxy which calls the stub
+NetworkAccessManager::NetworkAccessManager(QObject *parent)
+{
+ networkAccessManagerStub->NetworkAccessManagerConstructor(parent);
+}
+
+bool NetworkAccessManager::isConnected()
+{
+ return networkAccessManagerStub->isConnected();
+}
+
+QNetworkReply *NetworkAccessManager::get(const QNetworkRequest &request, bool onlineRequestsOnly)
+{
+ return networkAccessManagerStub->get(request, onlineRequestsOnly);
+}
+
+QNetworkReply *NetworkAccessManager::post(const QNetworkRequest &request, QByteArray &data,
+ bool onlineRequestsOnly)
+{
+ return networkAccessManagerStub->post(request, data, onlineRequestsOnly);
+}
+
+void NetworkAccessManager::setCache(QAbstractNetworkCache *cache)
+{
+ networkAccessManagerStub->setCache(cache);
+}
+
+QAbstractNetworkCache *NetworkAccessManager::cache() const
+{
+ return networkAccessManagerStub->cache();
+}
+
+void NetworkAccessManager::connected()
+{
+ networkAccessManagerStub->connected();
+}
+
+void NetworkAccessManager::disconnected()
+{
+ networkAccessManagerStub->disconnected();
+}
+
+void NetworkAccessManager::downloadFinished(QNetworkReply *reply)
+{
+ networkAccessManagerStub->downloadFinished(reply);
+}
+
+#endif // NETWORKACCESSMANAGERSTUB_H
--- /dev/null
+/***************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (directui@nokia.com)
+**
+** This file is part of mhome.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at directui@nokia.com.
+**
+** This 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
+** and appearing in the file LICENSE.LGPL included in the packaging
+** of this file.
+**
+****************************************************************************/
+#ifndef PARAMETER_H
+#define PARAMETER_H
+
+class ParameterBase
+{
+public:
+ virtual ~ParameterBase() {
+ // Class needs to have at least one virtual function to be polymorphic
+ // (and thus enable dynamic_cast)
+ }
+protected:
+ ParameterBase() {
+ }
+};
+
+template <typename T>
+class Parameter : public ParameterBase
+{
+public:
+ Parameter(T value) : ParameterBase(), data(value) {
+ }
+ T data;
+};
+#endif
--- /dev/null
+/***************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (directui@nokia.com)
+**
+** This file is part of mhome.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at directui@nokia.com.
+**
+** This 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
+** and appearing in the file LICENSE.LGPL included in the packaging
+** of this file.
+**
+****************************************************************************/
+
+#include <assert.h>
+#include "stubbase.h"
+#include "methodcall.h"
+
+QList<MethodCall *> StubBase::stubCallHistory() const
+{
+ return _stubCallHistory;
+}
+
+void StubBase::stubReset() const
+{
+ foreach(ParameterBase * p, _stubReturnValues) {
+ delete p;
+ }
+
+ foreach(MethodCall * p, _stubCallHistory) {
+ delete p;
+ }
+
+ _stubReturnValues.clear();
+ _stubCallCounts.clear();
+ _stubCallHistory.clear();
+}
+
+int StubBase::stubCallCount(const QString &method) const
+{
+ return _stubCallCounts[method];
+}
+
+void StubBase::stubMethodEntered(const QString &methodName, QList<ParameterBase *> params) const
+{
+ MethodCall *method = new MethodCall(methodName, params, stubReturnValue(methodName));
+ _stubCallCounts[methodName] = _stubCallCounts[methodName] + 1;
+ _stubCallHistory.append(method);
+}
+
+void StubBase::stubMethodEntered(const QString &methodName) const
+{
+ MethodCall *method = new MethodCall(methodName, QList<ParameterBase *>(), stubReturnValue(methodName));
+ _stubCallCounts[methodName] = _stubCallCounts[methodName] + 1;
+ _stubCallHistory.append(method);
+}
+
+ParameterBase *StubBase::stubReturnValue(const QString &methodName) const
+{
+ ParameterBase *retVal = NULL;
+
+ if (_stubReturnValues.contains(methodName))
+ retVal = _stubReturnValues[methodName];
+
+ return retVal;
+}
+
+StubBase::~StubBase()
+{
+ stubReset();
+}
+
+MethodCall &StubBase::stubLastCall() const
+{
+ return *(_stubCallHistory.last());
+}
+
+MethodCall &StubBase::stubLastCallTo(const QString &method) const
+{
+ for (int i = _stubCallHistory.count() - 1; i >= 0; i--) {
+ if (_stubCallHistory.at(i)->name() == method) {
+ return *(_stubCallHistory.at(i));
+ }
+ }
+ qDebug() << "StubBase::lastCallTo: call not found to:" << method;
+ return *((MethodCall *)0);
+}
+
+QList<MethodCall *> StubBase::stubCallsTo(const QString &method) const
+{
+ QList<MethodCall *> calls;
+ for (int i = 0; i < _stubCallHistory.count(); i++) {
+ if (_stubCallHistory.at(i)->name() == method) {
+ calls.append(_stubCallHistory.at(i));
+ }
+ }
+ return calls;
+}
+
+
--- /dev/null
+/***************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (directui@nokia.com)
+**
+** This file is part of mhome.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at directui@nokia.com.
+**
+** This 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
+** and appearing in the file LICENSE.LGPL included in the packaging
+** of this file.
+**
+****************************************************************************/
+
+#ifndef STUBBASE_H
+#define STUBBASE_H
+
+#include <QList>
+#include <QVariant>
+#include <QMap>
+#include <QtDebug>
+#include "parameter.h"
+#include "methodcall.h"
+
+
+class StubBase
+{
+public:
+ // Return a list of method calls
+ QList<MethodCall *> stubCallHistory() const;
+
+ // Return a reference to the last method call
+ MethodCall &stubLastCall() const;
+
+ // Access parameters of the last method call
+ template <typename T>
+ T stubLastParameters(int number) const;
+
+ // Access parameters of the last method call
+ MethodCall &stubLastCallTo(const QString &method) const;
+
+ // Return a list of calls to a particular method call
+ QList<MethodCall *> stubCallsTo(const QString &method) const;
+
+ // Return the number of times a method has been called
+ int stubCallCount(const QString &method) const;
+
+ // Set the return value for next call of methodName
+ template <typename T>
+ void stubSetReturnValue(const QString &methodName, T value) const;
+
+ // Return the return value set for methodName
+ template <typename T>
+ T &stubReturnValue(const QString &methodName) const;
+
+
+
+ // For use by stubs
+ virtual ~StubBase();
+ void stubReset() const;
+ ParameterBase *stubReturnValue(const QString &methodName) const;
+ void stubMethodEntered(const QString &methodName, QList<ParameterBase *> params) const;
+ void stubMethodEntered(const QString &methodName) const;
+
+private:
+ mutable QMap<QString, ParameterBase *> _stubReturnValues;
+ mutable QMap<QString, int> _stubCallCounts;
+ mutable QList<MethodCall *> _stubCallHistory;
+
+};
+
+template <typename T>
+void StubBase::stubSetReturnValue(const QString &methodName, T value) const
+{
+ Parameter<T>* param = new Parameter<T>(value);
+ _stubReturnValues[methodName] = param;
+}
+
+template <typename T>
+T &StubBase::stubReturnValue(const QString &methodName) const
+{
+ if (! _stubReturnValues.contains(methodName)) {
+ stubSetReturnValue<T>(methodName, T());
+ }
+
+ ParameterBase *base = _stubReturnValues[methodName];
+ Parameter<T>* param = dynamic_cast<Parameter<T>*>(base);
+ if (!param) {
+ QString msg = QString("StubBase::") + __func__ + ": failed dynamic_cast, check that return value type matches the method; check also that you have used stubSetReturnValue(" + methodName + ")";
+ qFatal("%s", qPrintable(msg));
+ }
+ return param->data;
+
+}
+
+template <typename T>
+T StubBase::stubLastParameters(int number) const
+{
+ MethodCall &call = stubLastCall();
+ return call.parameter<T>(number);
+}
+
+#endif
--- /dev/null
+HEADERS += \
+ stubbase.h \
+ methodcall.h \
+ parameter.h \
+ networkaccessmanagerstub.h \
+ imagefetcherstub.h
+
+SOURCES += \
+ stubbase.cpp
ui/avatarimage \
user \
routing/route \
- routing/routesegment
+ routing/routesegment \
+ situareservice