From 2c24f0b88ef202e33d5a5d3c77160ecb444c170a Mon Sep 17 00:00:00 2001 From: lampehe-local Date: Fri, 16 Apr 2010 13:38:33 +0300 Subject: [PATCH] First phase of facebookservice and situareservice integration. Renamed unit test folders and updated some unit tests. --- src/situareservice/situareservice.cpp | 36 ++++-- src/situareservice/situareservice.h | 12 +- src/src.pro | 11 +- tests/testcookiehandler/testcookiehandler.cpp | 58 --------- tests/testcookiehandler/testcookiehandler.pro | 15 --- .../networkaccessmanagermock.cpp | 107 ---------------- .../testlocationupdate/networkaccessmanagermock.h | 61 --------- .../testlocationupdate/networkreplymock.cpp | 67 ---------- .../testlocationupdate/networkreplymock.h | 55 -------- .../testlocationupdate/testlocationupdate.cpp | 126 ------------------- .../testlocationupdate/testlocationupdate.pro | 20 --- .../teststringformations/teststringformations.cpp | 132 -------------------- .../teststringformations/teststringformations.pro | 16 --- 13 files changed, 46 insertions(+), 670 deletions(-) delete mode 100644 tests/testcookiehandler/testcookiehandler.cpp delete mode 100644 tests/testcookiehandler/testcookiehandler.pro delete mode 100644 tests/testsituareservice/testlocationupdate/networkaccessmanagermock.cpp delete mode 100644 tests/testsituareservice/testlocationupdate/networkaccessmanagermock.h delete mode 100644 tests/testsituareservice/testlocationupdate/networkreplymock.cpp delete mode 100644 tests/testsituareservice/testlocationupdate/networkreplymock.h delete mode 100644 tests/testsituareservice/testlocationupdate/testlocationupdate.cpp delete mode 100644 tests/testsituareservice/testlocationupdate/testlocationupdate.pro delete mode 100644 tests/testsituareservice/teststringformations/teststringformations.cpp delete mode 100644 tests/testsituareservice/teststringformations/teststringformations.pro diff --git a/src/situareservice/situareservice.cpp b/src/situareservice/situareservice.cpp index 12a7aa3..d4bb7da 100644 --- a/src/situareservice/situareservice.cpp +++ b/src/situareservice/situareservice.cpp @@ -31,7 +31,11 @@ SituareService::SituareService(QObject *parent, QNetworkAccessManager *manager) { qDebug() << __PRETTY_FUNCTION__; + connect(&facebookAuthentication, SIGNAL(credentialsReady()), SLOT(credentialsReady())); // not final + connect(networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(requestFinished(QNetworkReply*))); + + credentials = facebookAuthentication.getLoginCredentials(); // not final } SituareService::~SituareService() @@ -45,8 +49,11 @@ void SituareService::updateLocation(QPointF coordinates, QString status, bool pu { qDebug() << __PRETTY_FUNCTION__; -// CookieHandler cookieHandler; -// QString cookie = cookieHandler.formCookie(); // ToDo: get the FB session credentials from somewhere, QSettings... + CookieHandler cookieHandler; + + QString cookie = cookieHandler.formCookie(API_KEY, credentials.getExpires(), credentials.getUserID(), credentials.getSessionKey(), + credentials.getSessionSecret(), credentials.getSig(), EN_LOCALE); + QString publishValue; if(publish) { @@ -58,21 +65,25 @@ void SituareService::updateLocation(QPointF coordinates, QString status, bool pu QString urlParameters = formUrlParameters(coordinates, status, publishValue); QUrl url = formUrl(SITUARE_URL, UPDATE_LOCATION, urlParameters); - //sendRequest(url, COOKIE, cookie); + sendRequest(url, COOKIE, cookie); } void SituareService::reverseGeo(QPointF coordinates) { -// CookieHandler cookieHandler; -// QString cookie = cookieHandler.formCookie(); // ToDo: get the FB session credentials from somewhere, QSettings... + qDebug() << __PRETTY_FUNCTION__; + + CookieHandler cookieHandler; + + QString cookie = cookieHandler.formCookie(API_KEY, credentials.getExpires(), credentials.getUserID(), credentials.getSessionKey(), + credentials.getSessionSecret(), credentials.getSig(), EN_LOCALE); QString urlParameters = formUrlParameters(coordinates); QUrl url = formUrl(SITUARE_URL, REVERSE_GEO, urlParameters); - //sendRequest(url, COOKIE, cookie); + sendRequest(url, COOKIE, cookie); } -QUrl SituareService::formUrl(QString baseUrl, QString phpScript, QString urlParameters) +QUrl SituareService::formUrl(const QString baseUrl, const QString phpScript, QString urlParameters) { qDebug() << __PRETTY_FUNCTION__; QString urlString; @@ -126,7 +137,7 @@ QString SituareService::formUrlParameters(QPointF coordinates, QString status, Q return parameters; } -void SituareService::sendRequest(QUrl url, QString cookieType, QString cookie) +void SituareService::sendRequest(QUrl url, const QString cookieType, QString cookie) { qDebug() << __PRETTY_FUNCTION__ << "url: " << url; @@ -160,14 +171,17 @@ void SituareService::requestFinished(QNetworkReply *reply) if(replyArray == ERROR_LAT.toAscii()) { qDebug() << "Error: " << ERROR_LAT; // ToDo: signal UI? + emit error(replyArray); } else if(replyArray == ERROR_LON.toAscii()) { qDebug() << "Error: " << ERROR_LON; // ToDo: signal UI? + emit error(replyArray); } else if(replyArray.contains(ERROR_SESSION.toAscii())) { qDebug() << "Error: " << ERROR_SESSION; // ToDo: signal UI? + emit error(replyArray); } else { // no error -> update was successful @@ -179,3 +193,9 @@ void SituareService::requestFinished(QNetworkReply *reply) currentRequests.removeAll(reply); reply->deleteLater(); } + +void SituareService::credentialsReady() +{ + qDebug() << __PRETTY_FUNCTION__; + credentials = facebookAuthentication.getLoginCredentials(); +} diff --git a/src/situareservice/situareservice.h b/src/situareservice/situareservice.h index 72d5b3e..df6570f 100644 --- a/src/situareservice/situareservice.h +++ b/src/situareservice/situareservice.h @@ -30,6 +30,9 @@ #include #include +#include "../facebookservice/facebookauthentication.h" // not final +#include "../facebookservice/facebookcredentials.h" // not final + /** * @brief SituareService class for communicating with Situare server * @@ -78,7 +81,7 @@ public: * @param urlParameters optional parameters for url * @return QUrl formed url */ - QUrl formUrl(QString baseUrl, QString phpScript, QString urlParameters = 0); + QUrl formUrl(const QString baseUrl, const QString phpScript, QString urlParameters = 0); /** * @brief Forms url parameters @@ -99,7 +102,7 @@ public: * @param cookieType type of the cookie * @param cookie http cookie */ - void sendRequest(QUrl url, QString cookieType, QString cookie); + void sendRequest(QUrl url, const QString cookieType, QString cookie); signals: @@ -121,9 +124,14 @@ public slots: */ void requestFinished(QNetworkReply *reply); + + void credentialsReady(); // not final + private: QNetworkAccessManager *networkManager; QList currentRequests; + FacebookAuthentication facebookAuthentication; // not final + FacebookCredentials credentials; // not final }; #endif // SITUARESERVICE_H diff --git a/src/src.pro b/src/src.pro index 7145f9b..0f41e42 100644 --- a/src/src.pro +++ b/src/src.pro @@ -8,15 +8,20 @@ SOURCES += main.cpp \ ui/mapviewscreen.cpp \ ui/listviewscreen.cpp \ situareservice/situareservice.cpp \ - cookiehandler/cookiehandler.cpp + cookiehandler/cookiehandler.cpp \ + facebookservice/facebookcredentials.cpp \ + facebookservice/facebookauthentication.cpp HEADERS += ui/mainwindow.h \ ui/mapviewscreen.h \ ui/listviewscreen.h \ situareservice/situareservice.h \ situareservice/situarecommon.h \ - cookiehandler/cookiehandler.h + cookiehandler/cookiehandler.h \ + facebookservice/facebookcredentials.h \ + facebookservice/facebookauthentication.h QT += core \ - network + network \ + webkit # ----------------------------------------------------------------- # Debian packetizing additions diff --git a/tests/testcookiehandler/testcookiehandler.cpp b/tests/testcookiehandler/testcookiehandler.cpp deleted file mode 100644 index e38a036..0000000 --- a/tests/testcookiehandler/testcookiehandler.cpp +++ /dev/null @@ -1,58 +0,0 @@ - /* - Situare - A location system for Facebook - Copyright (C) 2010 Ixonos Plc. Authors: - - Henri Lampela - henri.lampela@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 -#include - - -#include "../../src/cookiehandler/cookiehandler.h" -#include "../../src/situareservice/situarecommon.h" - - -class testCookieHandler : public QObject -{ - Q_OBJECT -private: - CookieHandler *cookieHandler; - -private slots: - - void testFormCookie(); - -}; - -void testCookieHandler::testFormCookie() -{ - const QString apiKey = "1"; - const QString expires = "2"; - const QString sessionKey = "3"; - const QString user = "4"; - const QString sessionSecret = "5"; - const QString signature = "6"; - const QString locale = "7"; - - QString cookie = cookieHandler->formCookie(apiKey, expires, user, sessionKey, sessionSecret, signature, locale); - - QCOMPARE(QString(";1_expires=2;1_session_key=3;1_user=4;1_ss=5;1=6;locale=7"), cookie); -} - -QTEST_MAIN(testCookieHandler) -#include "testcookiehandler.moc" diff --git a/tests/testcookiehandler/testcookiehandler.pro b/tests/testcookiehandler/testcookiehandler.pro deleted file mode 100644 index 6bd6b77..0000000 --- a/tests/testcookiehandler/testcookiehandler.pro +++ /dev/null @@ -1,15 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Fri Apr 9 13:34:34 2010 -###################################################################### - -CONFIG += qtestlib -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input -HEADERS += ../../src/cookiehandler/cookiehandler.h \ - ../../src/situareservice/situarecommon.h -SOURCES += testcookiehandler.cpp \ - ../../src/cookiehandler/cookiehandler.cpp diff --git a/tests/testsituareservice/testlocationupdate/networkaccessmanagermock.cpp b/tests/testsituareservice/testlocationupdate/networkaccessmanagermock.cpp deleted file mode 100644 index 73af5fc..0000000 --- a/tests/testsituareservice/testlocationupdate/networkaccessmanagermock.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - Situare - A location system for Facebook - Copyright (C) 2010 Ixonos Plc. Authors: - - Henri Lampela - henri.lampela@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 -#include -#include "networkaccessmanagermock.h" - -NetworkAccessManagerMock::NetworkAccessManagerMock(QNetworkAccessManager *manager, QObject *parent) - : QNetworkAccessManager(parent) - , mode(0) -{ - qDebug() << __PRETTY_FUNCTION__; -} - -NetworkReplyMock *NetworkAccessManagerMock::createRequest(Operation op, const QNetworkRequest &request, - QIODevice *outgoingData) -{ - qDebug() << __PRETTY_FUNCTION__; - - reply = new NetworkReplyMock(this); - this->request = request; - - switch (this->mode) { - - case NetworkAccessManagerMock::CORRECT: - QTimer::singleShot(0, this, SLOT(generateCorrectReply())); - break; - case NetworkAccessManagerMock::INCORRECT: - QTimer::singleShot(0, this, SLOT(generateError())); - break; - case NetworkAccessManagerMock::DELAYED_CORRECT: - QTimer::singleShot(0, this, SLOT(generateDelayedCorrectReply())); - break; - default: - QTimer::singleShot(0, this, SLOT(generateCorrectReply())); - break; - } - return reply; -} - -NetworkReplyMock *NetworkAccessManagerMock::get(const QNetworkRequest &request) -{ - qDebug() << __PRETTY_FUNCTION__; - this->request = request; - - return reply; -} - -void NetworkAccessManagerMock::setMode(int mode) -{ - this->mode = mode; -} - -void NetworkAccessManagerMock::generateError() -{ - qDebug() << __PRETTY_FUNCTION__; - reply->setUrl(request.url()); - reply->setError(QNetworkReply::HostNotFoundError, "Host not found"); - emit QNetworkAccessManager::finished(reply); -} - -void NetworkAccessManagerMock::generateCorrectReply() -{ - qDebug() << __PRETTY_FUNCTION__; - reply->setUrl(request.url()); - reply->setError(QNetworkReply::NoError, "No error"); -// QImage image; -// if (!image.load(":testTile.png", 0)) { -// qDebug() << "could not load image"; -// image = QImage(); -// } -// else -// qDebug() << "image loaded"; -// -// QByteArray array; -// QBuffer buffer(&array); -// buffer.open(QBuffer::WriteOnly); -// if (image.save(&buffer, "PNG")) -// qDebug() << "image saved"; -// buffer.close(); -// reply->setData(array); - emit QNetworkAccessManager::finished(reply); -} - -void NetworkAccessManagerMock::generateDelayedCorrectReply() -{ - qDebug() << __PRETTY_FUNCTION__; - QTimer::singleShot(4000, this, SLOT(generateCorrectReply())); -} diff --git a/tests/testsituareservice/testlocationupdate/networkaccessmanagermock.h b/tests/testsituareservice/testlocationupdate/networkaccessmanagermock.h deleted file mode 100644 index 77b51ab..0000000 --- a/tests/testsituareservice/testlocationupdate/networkaccessmanagermock.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - Situare - A location system for Facebook - Copyright (C) 2010 Ixonos Plc. Authors: - - Henri Lampela - henri.lampela@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 NETWORKACCESSMANAGERMOCK_H -#define NETWORKACCESSMANAGERMOCK_H - -#include -#include -#include -#include "networkreplymock.h" - - -class NetworkAccessManagerMock : public QNetworkAccessManager -{ - Q_OBJECT -public: - NetworkAccessManagerMock(QNetworkAccessManager *manager = 0, QObject *parent = 0); - - NetworkReplyMock *get(const QNetworkRequest &request); - - void setMode(int mode); - - - enum {CORRECT, INCORRECT, DELAYED_CORRECT}; - -protected: - NetworkReplyMock *createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData); - -signals: - void finished(NetworkReplyMock *reply); - - private slots: - void generateError(); - void generateCorrectReply(); - void generateDelayedCorrectReply(); - -private: - NetworkReplyMock *reply; - QNetworkRequest request; - int mode; -}; - -#endif // NETWORKACCESSMANAGERMOCK_H diff --git a/tests/testsituareservice/testlocationupdate/networkreplymock.cpp b/tests/testsituareservice/testlocationupdate/networkreplymock.cpp deleted file mode 100644 index 2e94b85..0000000 --- a/tests/testsituareservice/testlocationupdate/networkreplymock.cpp +++ /dev/null @@ -1,67 +0,0 @@ - -#include -#include -#include "networkreplymock.h" - -NetworkReplyMock::NetworkReplyMock(QObject *parent) - : QNetworkReply(parent) - , m_offset(0) -{ -} - -void NetworkReplyMock::setError(NetworkError errorCode, const QString &errorString) -{ - qDebug() << __PRETTY_FUNCTION__; - QNetworkReply::setError(errorCode, errorString); -} - - -qint64 NetworkReplyMock::readData(char *data, qint64 maxLen) -{ - qDebug() << __PRETTY_FUNCTION__; - if (m_offset < m_content.size()) { - qint64 number = qMin(maxLen, m_content.size() - m_offset); - memcpy(data, m_content.constData() + m_offset, number); - m_offset += number; - return number; - } - else { - return -1; - } -} - -QByteArray NetworkReplyMock::readAll() -{ - return m_content; -} - -qint64 NetworkReplyMock::bytesAvailable() const -{ - qDebug() << __PRETTY_FUNCTION__; - return m_content.size() - m_offset; -} - -void NetworkReplyMock::setUrl(const QUrl &url) -{ - qDebug() << __PRETTY_FUNCTION__; - QNetworkReply::setUrl(url); -} - -void NetworkReplyMock::abort() -{ - qDebug() << __PRETTY_FUNCTION__; -} - -void NetworkReplyMock::test() -{ - qDebug() << __PRETTY_FUNCTION__; -} - -void NetworkReplyMock::setData(const QByteArray &content) -{ - qDebug() << __PRETTY_FUNCTION__; -// setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/png")); -// setHeader(QNetworkRequest::ContentLengthHeader, QVariant(this->m_content.size())); -// m_content.append(content); -// qDebug() << "Content size: " << m_content.size(); -} diff --git a/tests/testsituareservice/testlocationupdate/networkreplymock.h b/tests/testsituareservice/testlocationupdate/networkreplymock.h deleted file mode 100644 index fcb4108..0000000 --- a/tests/testsituareservice/testlocationupdate/networkreplymock.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Situare - A location system for Facebook - Copyright (C) 2010 Ixonos Plc. Authors: - - Henri Lampela - henri.lampela@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 NETWORKREPLYMOCK_H -#define NETWORKREPLYMOCK_H - -#include -#include - - -class NetworkReplyMock : public QNetworkReply -{ - Q_OBJECT -public: - NetworkReplyMock(QObject *parent = 0); - void abort(); - qint64 bytesAvailable() const; - - bool isSequential() const - { - return true; - } - void setError(NetworkError errorCode, const QString &errorString); - void setData(const QByteArray &content); - void setUrl(const QUrl &url); - void test(); - QByteArray readAll(); - -protected: - qint64 readData(char *data, qint64 maxlen); - -private: - QByteArray m_content; - qint64 m_offset; -}; - -#endif // NETWORKREPLYMOCK_H diff --git a/tests/testsituareservice/testlocationupdate/testlocationupdate.cpp b/tests/testsituareservice/testlocationupdate/testlocationupdate.cpp deleted file mode 100644 index 03445dc..0000000 --- a/tests/testsituareservice/testlocationupdate/testlocationupdate.cpp +++ /dev/null @@ -1,126 +0,0 @@ - /* - Situare - A location system for Facebook - Copyright (C) 2010 Ixonos Plc. Authors: - - Henri Lampela - henri.lampela@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 -#include -#include -#include - - -#include "../../../src/situareservice/situareservice.h" -#include "../../../src/situareservice/situarecommon.h" -#include "networkaccessmanagermock.h" -#include "networkreplymock.h" - - -class testLocationUpdate : public QObject -{ - Q_OBJECT -private: - SituareService *situare; - NetworkAccessManagerMock *managerMock; - QList currentRequests; - -private slots: - - void testIncorrectUrl(); - void testCorrectUrl(); -}; - - -void testLocationUpdate::testIncorrectUrl() -{ - QNetworkAccessManager *manager = new QNetworkAccessManager(); - managerMock = new NetworkAccessManagerMock(manager, this); - situare = new SituareService(this, manager); - - managerMock->setMode(NetworkAccessManagerMock::INCORRECT); - - QSignalSpy receivedErrorSpy(situare, SIGNAL(error(QString))); - - QVERIFY(receivedErrorSpy.isValid()); - - // incorrect url - - situare->sendRequest(QUrl("http://client.situare.nett"), COOKIE, QString(";2;1")); - QTest::qWait(1000); - QCOMPARE(receivedErrorSpy.count(), 1); - - delete manager; - //delete situare; -} - -void testLocationUpdate::testCorrectUrl() -{ - QNetworkAccessManager *manager = new QNetworkAccessManager(); - managerMock = new NetworkAccessManagerMock(manager, this); - situare = new SituareService(this, manager); - - managerMock->setMode(NetworkAccessManagerMock::CORRECT); - - QSignalSpy receivedErrorSpy(situare, SIGNAL(error(QString))); - - QVERIFY(receivedErrorSpy.isValid()); - - QUrl url = QUrl("http://client.situare.net"); - - situare->sendRequest(url, COOKIE, QString(";2;1")); - QTest::qWait(1000); - - QCOMPARE(receivedErrorSpy.count(), 0); - - delete manager; - delete situare; -} - -void testLocationUpdate::testLocationUpdateUnPublishWithStatus() -{ - manager = new NetworkAccessManagerMock(); - situare = new SituareService(this, manager); - - QPointF coordinates(65, 25.5); - bool publish = false; - QString status = "test - no publish"; - situare->updateLocation(coordinates, status, publish); - - delete manager; - delete situare; -} - -void testLocationUpdate::testLocationUpdateUnPublishWithoutStatus() -{ - manager = new NetworkAccessManagerMock(); - situare = new SituareService(this, manager); - - QPointF coordinates(65, 25.5); - bool publish = false; - QString status = ""; - situare->updateLocation(coordinates, status, publish); - - delete manager; - delete situare; -} - - - - -QTEST_MAIN(testLocationUpdate) -#include "testlocationupdate.moc" diff --git a/tests/testsituareservice/testlocationupdate/testlocationupdate.pro b/tests/testsituareservice/testlocationupdate/testlocationupdate.pro deleted file mode 100644 index 760bc42..0000000 --- a/tests/testsituareservice/testlocationupdate/testlocationupdate.pro +++ /dev/null @@ -1,20 +0,0 @@ -# ##################################################################### -# Automatically generated by qmake (2.01a) Wed Apr 7 16:44:14 2010 -# ##################################################################### -CONFIG += qtestlib -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input -HEADERS += ../../../src/situareservice/situareservice.h \ - testlocationupdate.moc \ - networkreplymock.h \ - networkaccessmanagermock.h -SOURCES += testlocationupdate.cpp \ - ../../../src/situareservice/situareservice.cpp \ - networkreplymock.cpp \ - networkaccessmanagermock.cpp -QT += core \ - network diff --git a/tests/testsituareservice/teststringformations/teststringformations.cpp b/tests/testsituareservice/teststringformations/teststringformations.cpp deleted file mode 100644 index 314990b..0000000 --- a/tests/testsituareservice/teststringformations/teststringformations.cpp +++ /dev/null @@ -1,132 +0,0 @@ - /* - Situare - A location system for Facebook - Copyright (C) 2010 Ixonos Plc. Authors: - - Henri Lampela - henri.lampela@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 -#include -#include - - -#include "../../../src/situareservice/situareservice.h" -#include "../../../src/situareservice/situarecommon.h" - - -class testStringFormations : public QObject -{ - Q_OBJECT -private: - SituareService *situare; - -private slots: - - void testWithNoPublishNoStatus(); // part 1 of testFormUrlParameters - void testWithStatusNoPublish(); // part 2 of testFormUrlParameters - void testWithPublishTrueNoStatus(); // part 3 of testFormUrlParameters - void testWithStatusPublishTrue(); // part 4 of testFormUrlParameters - void testWithStatusPublishFalse(); // part 5 of testFormUrlParameters - void testWithPublishFalseNoStatus(); // part 6 of testFormUrlParameters - - void testFormUpdateLocationUrl(); // updateLocation url test - void testFormReverseGeoUrl(); // reverseGeo url test - -}; - -void testStringFormations::testWithNoPublishNoStatus() -{ - QPointF coordinates(65.3, 25.5); - QString publish = ""; - QString status = ""; - QString params = situare->formUrlParameters(coordinates, status, publish); - - QCOMPARE(QString("?lat=65.3&lon=25.5"), params); -} - -void testStringFormations::testWithStatusNoPublish() -{ - QPointF coordinates(65.3, 25.5); - QString publish = ""; - QString status = "testing"; - QString params = situare->formUrlParameters(coordinates, status, publish); - - QCOMPARE(QString("?lat=65.3&lon=25.5&data=testing"), params); -} - -void testStringFormations::testWithPublishTrueNoStatus() -{ - QPointF coordinates(65.3, 25.5); - QString publish = "true"; - QString status = ""; - QString params = situare->formUrlParameters(coordinates, status, publish); - - QCOMPARE(QString("?lat=65.3&lon=25.5&publish=true"), params); -} - -void testStringFormations::testWithStatusPublishTrue() -{ - QPointF coordinates(65.3, 25.5); - QString publish = "true"; - QString status = "testing"; - QString params = situare->formUrlParameters(coordinates, status, publish); - - QCOMPARE(QString("?lat=65.3&lon=25.5&publish=true&data=testing"), params); -} - -void testStringFormations::testWithStatusPublishFalse() -{ - QPointF coordinates(65.3, 25.5); - QString publish = "false"; - QString status = "testing"; - QString params = situare->formUrlParameters(coordinates, status, publish); - - QCOMPARE(QString("?lat=65.3&lon=25.5&publish=false&data=testing"), params); -} - -void testStringFormations::testWithPublishFalseNoStatus() -{ - QPointF coordinates(65.3, 25.5); - QString publish = "false"; - QString status = ""; - QString params = situare->formUrlParameters(coordinates, status, publish); - - QCOMPARE(QString("?lat=65.3&lon=25.5&publish=false"), params); -} - -void testStringFormations::testFormUpdateLocationUrl() -{ - QString urlParameters = "?lat=65.3&lon=25.5&publish=false"; - QUrl url = situare->formUrl(SITUARE_URL, UPDATE_LOCATION, urlParameters); - - QCOMPARE(QString("http://client.situare.net/updateLocation.php?lat=65.3&lon=25.5&publish=false"), url.toString()); -} - -void testStringFormations::testFormReverseGeoUrl() -{ - QPointF coordinates(65.3, 25.5); - - QString params = situare->formUrlParameters(coordinates); - - QUrl url = situare->formUrl(SITUARE_URL, REVERSE_GEO, params); - - QCOMPARE(QString("http://client.situare.net/reversegeo.php?lat=65.3&lon=25.5"), url.toString()); -} - - -QTEST_MAIN(testStringFormations) -#include "teststringformations.moc" diff --git a/tests/testsituareservice/teststringformations/teststringformations.pro b/tests/testsituareservice/teststringformations/teststringformations.pro deleted file mode 100644 index 5e2e0d2..0000000 --- a/tests/testsituareservice/teststringformations/teststringformations.pro +++ /dev/null @@ -1,16 +0,0 @@ -# ##################################################################### -# Automatically generated by qmake (2.01a) Thu Apr 8 14:56:57 2010 -# ##################################################################### -CONFIG += qtestlib -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input -HEADERS += ../../../src/situareservice/situareservice.h - -SOURCES += teststringformations.cpp \ - ../../../src/situareservice/situareservice.cpp -QT = core \ - network -- 1.7.9.5