2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Henri Lampela - henri.lampela@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 #include <QtTest/QtTest>
26 #include "../../../src/situareservice/situareservice.h"
27 #include "../../../src/situareservice/situarecommon.h"
28 #include "../../../src/facebookservice/facebookauthentication.h"
31 class testLocationUpdate : public QObject
35 ~testLocationUpdate();
37 SituareService *situare;
38 QList<QNetworkReply *> currentRequests;
39 FacebookAuthentication fbAuthentication;
40 FacebookCredentials credentials;
44 //void testIncorrectUrl();
45 //void testCorrectUrl();
46 void testLocationUpdateCase();
49 testLocationUpdate::~testLocationUpdate()
55 //void testLocationUpdate::testIncorrectUrl()
57 // QNetworkAccessManager *manager = new QNetworkAccessManager();
58 // managerMock = new NetworkAccessManagerMock(manager, this);
59 // situare = new SituareService(this, manager);
61 // managerMock->setMode(NetworkAccessManagerMock::INCORRECT);
63 // QSignalSpy receivedErrorSpy(situare, SIGNAL(error(QString)));
65 // QVERIFY(receivedErrorSpy.isValid());
69 // situare->sendRequest(QUrl("http://client.situare.nett"), COOKIE, QString(""));
70 // QTest::qWait(1000);
71 // QCOMPARE(receivedErrorSpy.count(), 1);
76 //void testLocationUpdate::testCorrectUrl()
78 // QNetworkAccessManager *manager = new QNetworkAccessManager();
79 // managerMock = new NetworkAccessManagerMock(manager, this);
80 // situare = new SituareService(this, manager);
82 // managerMock->setMode(NetworkAccessManagerMock::CORRECT);
84 // QSignalSpy receivedErrorSpy(situare, SIGNAL(error(QString)));
86 // QVERIFY(receivedErrorSpy.isValid());
88 // QUrl url = QUrl("http://client.situare.net");
90 // situare->sendRequest(url, COOKIE, QString(""));
91 // QTest::qWait(1000);
93 // QCOMPARE(receivedErrorSpy.count(), 0);
98 void testLocationUpdate::testLocationUpdateCase()
100 situare = new SituareService(this);
102 QSignalSpy receivedErrorSpy(situare, SIGNAL(error(QString)));
104 QPointF coordinates(65.3, 25.5);
106 QString status = "unit-test";
108 situare->updateLocation(coordinates, status, publish);
111 QCOMPARE(receivedErrorSpy.count(), 0);
115 QTEST_MAIN(testLocationUpdate)
116 #include "testlocationupdate.moc"